Omni Account can automatically swap your tokens when executing the transaction.

Say, you only have USDC on Base but want to transact with ETH on Arbitrum. In that case, you only need to specify the required tokens on the target chain, and Omni Account will do the bridging and the swap in one go.

To make your first cross-chain swap, make sure that:

  1. The account is deployed on any chain.
  2. The account has at least one of the supported assets on the chain with the deployed account.
const ethTarget = getTokenAddress('ETH', arbitrumSepolia.id)
const ethAmount = 2n
const receiver = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'

const transaction = await rhinestoneAccount.sendTransaction({
  sourceChain: baseSepolia,
  targetChain: arbitrumSepolia,
  calls: [
    {
      to: receiver,
      value: ethAmount,
    },
  ],
  tokenRequests: [
    {
      address: ethTarget,
      amount: ethAmount,
    },
  ],
})

Assuming you had USDC on Base Sepolia, this will swap some of that USDC to ETH, send it to Arbitrum Sepolia, and execute the transfer transaction.

Make sure the token address in calls and tokenRequests corresponds to the target chain.

Token Requests

tokenRequests is a list of token assets and their amounts that are required on the target chain to make the transaction. It tells the solvers to ensure those assets are present before executing the transaction calls. If you don’t need any assets on the target chain, you can omit this.

Solvers will supply all assets specified in the tokenRequests. If the user already has the required assets, don’t add them into tokenRequests.

Gas Limit

You can override the default gas limit for the target chain execution with gasLimit. Doing this will make the intent better priced, because we can more accurately calculate the fee that a solver needs to be reimbursed with for paying the gas. If this is not provided, we calculate using a gas limit of 1_000_000.

const transaction = await rhinestoneAccount.sendTransaction({
  sourceChain: baseSepolia,
  targetChain: arbitrumSepolia,
  calls: [
    // …
  ],
  tokenRequests: [
    // …
  ],
  gasLimit: 200_000n,
})

Source Chain

Providing the source chain deploys the account on that chain, as well as uses the funds on that chain to fulfill the intent.

If you already have an account deployed on one or more source chains, you can omit the sourceChain. In that case, the orchestrator will use the best chain(s) to source funds.

Providing a sourceChain is required when working with session keys.