Skip to main content

Send a single-chain transaction

Call sendTransaction with a chain and a list of calls. The example below transfers USDC on Base Sepolia:
import { encodeFunctionData, erc20Abi } from 'viem'
import { baseSepolia } from 'viem/chains'

const receiver = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'
const usdcAmount = 1n

const transaction = await rhinestoneAccount.sendTransaction({
  chain: baseSepolia,
  calls: [
    {
      to: 'USDC',
      value: 0n,
      data: encodeFunctionData({
        abi: erc20Abi,
        functionName: 'transfer',
        args: [receiver, usdcAmount],
      }),
    },
  ],
})

const result = await rhinestoneAccount.waitForExecution(transaction)
console.log('Result', result)

Send a cross-chain transaction

Swap chain for sourceChains + targetChain. The SDK handles bridging and routing with no separate bridge interaction required:
import { baseSepolia, arbitrumSepolia } from 'viem/chains'

const transaction = await rhinestoneAccount.sendTransaction({
  sourceChains: [baseSepolia],
  targetChain: arbitrumSepolia,
  calls: [
    {
      to: 'USDC',
      value: 0n,
      data: encodeFunctionData({
        abi: erc20Abi,
        functionName: 'transfer',
        args: [receiver, usdcAmount],
      }),
    },
  ],
  tokenRequests: [
    {
      address: 'USDC',
      amount: usdcAmount,
    },
  ],
})

const result = await rhinestoneAccount.waitForExecution(transaction)

Use the granular API

Use prepareTransactionsignTransactionsubmitTransaction when you need to separate fetching from signing. For example, to show the user transaction details before they approve, or to fetch intent data on a backend and sign on a mobile frontend:
// Fetch intent data (can be done server-side)
const transactionData = await rhinestoneAccount.prepareTransaction({
  chain: baseSepolia,
  calls: [...],
})

// Sign: prompts account owners
const signedData = await rhinestoneAccount.signTransaction(transactionData)

// Submit
const transaction = await rhinestoneAccount.submitTransaction(signedData)
To deploy the account on a specific chain before transacting, call await rhinestoneAccount.deploy(chain) first.

Next steps

Crosschain

Send funds across chains with a single signature. No bridging required.

Unified balance

Aggregate user balances across chains to fund any intent.

Sponsor fees

Cover gas, bridging, and swap fees for your users.