Contract Call

Call contract on different destination chain

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.

const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const address = signer.getAddress();
const contractInterface = new ethers.Interface(ABI); // create interface with your own ABI

const destinationPayload = contractInterface.encodeFunctionData("mint", [
  address,
  1000000000000,
]); // Replace with your own function name and parameters

const tx = await aarcSDK.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);

Last updated