Skip to main content
Analyzes available bridges and returns the optimal route with best pricing. Parameters:
  • tokenIn (required): Input token contract address
  • tokenOut (required): Output token contract address
  • sourceChain (required): Source blockchain
  • destinationChain (required): Destination blockchain
  • amount (required): Transfer amount in token units (wei for ETH)
  • amountSymbol (required): The denomination of the amount (e.g., USDC, DAI, ETH).
  • recipient (optional): Recipient address (required for some bridges like RhinoFi)
The amountSymbol parameter is used to specify the denomination of the amount you want to send. For quotes in USD, you need to set amountSymbol to USDC.You can quote in a different denomination than the token you want to send. For example, you can set amountSymbol to USDC, while sending ETH as tokenIn
import { crapi, Chainrails } from "@chainrails/sdk"

Chainrails.config({
  api_key: "your_api_key_here"
})

const route = await crapi.router.getOptimalRoutes({
  tokenIn: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
  tokenOut: "0xA0b86a33E6411192B1F4ec3eB801B21EB56",
  sourceChain: "BASE_MAINNET",
  destinationChain: "ARBITRUM_MAINNET",
  amount: "1000000000000000000",
  amountSymbol: "USDC",
  recipient: "0x742d35cc6634c0532925a3b8d7389d8c5b7cf15b"
})

console.log("Optimal route:", route)