Parameters

PropertyDescriptionRequired
chainIdThe chain id to deposit funds on
toChainIdThe chain id to execute the txs on
currencyAddress for a supported native currency or valid erc20
toCurrencyAddress for a supported native currency or valid erc20
tradeTypeEither EXACT_INPUT or EXACT_OUTPUT, this will inform the api whether or not to use the amount as the input or the output for the trade.
amountAmount in wei, in the supplied currency
walletA valid WalletClient from viem or an adapted wallet generated from an adapter that meets this interface.
recipientA valid address to send the funds to, defaults to wallet address if not sepcified
txsAn array of either transaction objects (made up of a to, data and value properties) or viem request objects returned from viem’s simulateContract function.
optionsAdditional options that map directly to the quote API.

Native Bridge Example

import { getClient } from "@reservoir0x/relay-sdk";
import { useWalletClient } from "wagmi";

const { data: wallet } = useWalletClient();

const quote = await getClient()?.actions.getQuote({
  chainId: 1,
  toChainId: 10,
  currency: "0x0000000000000000000000000000000000000000",
  toCurrency: "0x0000000000000000000000000000000000000000",
  value: "10000000000000000", // 0.01 ETH
  wallet,
});

Cross-Chain Swap Example

// Cross-Chain Swap from USDC on Ethereum to DAI on Optimism
const quote = await getClient()?.actions.getQuote({
  chainId: 1,
  toChainId: 10,
  currency: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC on Ethereum
  toCurrency: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", // DAI on Optimism
  value: "100000", // 100 USDC
  wallet,
});

Wrap/Unwrap Example

// Unwrap ETH
const quote = await getClient()?.actions.getQuote({
  chainId: 1,
  toChainId: 1,
  currency: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
  toCurrency: "0x0000000000000000000000000000000000000000",
  value: "10000000000000000", // 0.01 ETH
  wallet,
});

Send Example

// Send ERC20 / Native Currency to another address on the same chain
// Note: The recipient address must be specified for send transactions and be different from the wallet address
const quote = await getClient()?.actions.getQuote({
  chainId: 1,
  toChainId: 1,
  currency: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
  toCurrency: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  value: "100000", // 100 USDC
  wallet,
  recipient: "0x0000c3caa36e2d9a8cd5269c976ede05018f0000",
});

Note - Quotes can go stale after 30 seconds. Clients should regularly fetch fresh quotes so that users are always submitting valid transactions. See Getting a quote for more information on how quotes work.