> ## Documentation Index
> Fetch the complete documentation index at: https://aarc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cross-Chain Swap

> Call your contract with custom payload on different destination chain

The `getDepositAddress` function allows developers to interact with contracts on a different destination chain. For instance, if a user holds funds on \`Arbitrum\` but needs to call a contract on `Polygon`, they can achieve this seamlessly by generating a deposit address with `getDepositAddress` and submitting the payload on-chain.

### Expected parameters

`getDepositAddress` accepts following [parameters](buy-tokens#payload).

### Function Call

The `getDepositAddress` function generates an address based on the provided payload, which must then be funded and submitted on-chain.\\

<Tabs>
  <Tab title="ethers.js">
    ```typescript theme={null}
    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 payload: any = {
            // ... remaining params
            destinationRecipient : YOUR_CONTRACT_ADDRESS, 
            targetCalldata: destinationPayload
    };

    const depositData = await aarcCoreSDK.getDepositAddress(payload); 

    // make client sign the generated tx
    const { to, value, data, gasLimit, chainId, from } = depositData.txData;
    const txHash = await signer.sendTransaction({ to, value, data, gasLimit, chainId, from });
    ```
  </Tab>

  <Tab title="viem">
    ```typescript theme={null}
    import { createWalletClient, custom } from "viem";

    const getWalletClient = async () => {
    const [account] = await window.ethereum.request({
    method: "eth_requestAccounts",
      });
      const walletClient = createWalletClient({
        chain: arbitrum,
        account,
        transport: custom(window.ethereum!),
      });
      return walletClient;
    };

    const wallet = await getWalletClient();

    const [address] = await wallet.requestAddresses();

    const destinationPayload = encodeFunctionData({
      abi: ABI, // Replace with your ABI
      functionName: "mint",
      args: [address, 1000000000000],
    }); // Replace with your own function name and parameters

    const payload: any = {
            // ... remaining params
            targetCalldata: destinationPayload
    };

    const depositData = await aarcCoreSDK.getDepositAddress(payload); 

    // make client sign the generated tx
    const { to, value, data, gasLimit, chainId, from } = depositData.txData;
    const txHash = await signer.sendTransaction({ to, value, data, gasLimit, chainId, from });

    console.log('tx', tx);
    ```
  </Tab>
</Tabs>

Using onramp for contract call

```typescript theme={null}
// Using moonpay for onramp (you can also use kado)
const payload = {
    // rest of the payload,
    transferType: "onramp",  
};

const provider = "moonpay"; 

const url = await aarcCoreSDK.generateMoonpayOnrampUrl({
        walletAddress: depositAddressData.depositAddress,
        defaultCryptoCurrencyCode: depositAddressData.depositTokenSymbol,
        fiatAmount: fromToken.amount_required,
        fiatCurrencyCode: "USD",
        network: "BASE",
        cryptoTokenData: {
          tokenAmount: fromToken.amount_required,
          tokenCode: depositAddressData.depositTokenSymbol ?? "ETH",
        },
      });

const windowRef = window.open(url, "_blank");
```

For more comprehensive implementation, refer [cookbook](../cookbook/sdk-implementation-in-typescript-+-ethers) example.  &#x20;
