Parameters

PropertyDescriptionRequired
originChainIdThe chain id to deposit funds on
destinationChainIdThe chain id to execute the txs on
originCurrencyAddress for a supported native currency or valid erc20
destinationCurrencyAddress for a supported native currency or valid erc20
tradeTypeEither EXACT_INPUT for quoting via an input amount, or EXPECTED_OUTPUT/EXACT_OUTPUT for quoting via an output amount.
amountAmount in wei, in the supplied currency
userThe wallet address initiating the relay
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 price API

Native Bridge Example

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

const { data: wallet } = useWalletClient();

const price = await getClient()?.actions.getPrice({
  originChainId: 1,
  destinationChainId: 10,
  originCurrency: "0x0000000000000000000000000000000000000000",
  destinationCurrency: "0x0000000000000000000000000000000000000000",
  amount: "10000000000000000", // 0.01 ETH
  user: "0x03508bB71268BBA25ECaCC8F620e018666501111"
});

Cross-Chain Swap Example

// Cross-Chain Swap from USDC on Ethereum to DAI on Optimism
const price = await getClient()?.actions.getPrice({
  originChainId: 1,
  destinationChainId: 10,
  originCurrency: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC on Ethereum
  destinationCurrency: "0xda10009cbd5d07dd0cecc66161fc93d7c9000da1", // DAI on Optimism
  amount: "100000", // 100 USDC
  user: "0x03508bB71268BBA25ECaCC8F620e018666501111"
});

Wrap/Unwrap Example

// Unwrap ETH
const price = await getClient()?.actions.getPrice({
  originChainId: 1,
  destinationChainId: 1,
  originCurrency: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
  destinationCurrency: "0x0000000000000000000000000000000000000000",
  amount: "10000000000000000", // 0.01 ETH
  user: "0x03508bB71268BBA25ECaCC8F620e018666501111"
});

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 price = await getClient()?.actions.getPrice({
  originChainId: 1,
  destinationChainId: 1,
  originCurrency: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC
  destinationCurrency: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  amount: "100000", // 100 USDC
  user: "0x03508bB71268BBA25ECaCC8F620e018666501111",
  recipient: "0x0000c3caa36e2d9a8cd5269c976ede05018f0000",
});

The Price is a lightweight quote, excluding steps and calldata but it includes a preview of what the full quote might contain. Prices are subject to change once you get the quote so you should handle price changes accordingly.