The performCheckout function enables developers to call a contract on a different destination chain. For example, if a user has funds on arbitrum and wants to call a contract on polygon, they can easily do so using the performCheckout function.
Expected parameters
performCheckout accepts following parameters
Function Call
performCheckout function will initiate all required transactions on source chain such as getting an approval and sending tokens and calling contract on destination chain.
constprovider=newethers.BrowserProvider(window.ethereum);constsigner=awaitprovider.getSigner();constaddress=signer.getAddress();constcontractInterface=newethers.Interface(ABI); // create interface with your own ABIconstdestinationPayload=contractInterface.encodeFunctionData("mint", [ address,1000000000000,]); // Replace with your own function name and parametersconsttx=awaitaarcSDK.performCheckout({ toChainId:polygon.id, fromChainId:arbitrum.id, destinationPayload, destinationGasLimit:2000000,// Change gas limit as per your requirement fromAddress: address, toTokenAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",// Replace with your token Address fromTokenAddress:"0x912CE59144191C1204E64559FE8253a0e49E6548",// Replace with your token Address targetContractAddress:"0x6D8473f39AB16b7aE854d90acDcCDC83fa3A32b4",// Replace with your contract Address senderSigner: signer, toAmount:"10000000",// Amount of token needs to be send to contract});console.log('tx', tx);
import { createWalletClient, custom } from"viem";constgetWalletClient=async () => {const [account] =awaitwindow.ethereum.request({ method:"eth_requestAccounts", });constwalletClient=createWalletClient({ chain: arbitrum, account, transport:custom(window.ethereum!), });return walletClient;};constwallet=awaitgetWalletClient();const [address] =awaitwallet.requestAddresses();constdestinationPayload=encodeFunctionData({ abi:ABI,// Replace with your ABI functionName:"mint", args: [address,1000000000000],}); // Replace with your own function name and parametersconsttx=awaitaarcSDK.performCheckout({ toChainId:polygon.id, fromChainId:arbitrum.id, destinationPayload, destinationGasLimit:2000000,// Change gas limit as per your requirement fromAddress: address, toTokenAddress:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",// Replace with your token Address fromTokenAddress:"0x912CE59144191C1204E64559FE8253a0e49E6548",// Replace with your token Address targetContractAddress:"0x6D8473f39AB16b7aE854d90acDcCDC83fa3A32b4",// Replace with your contract Address senderSigner: wallet asany, toAmount:"10000000",// Amount of token needs to be send to contract});console.log('tx', tx);