Payments

Find Routes

Use thirdweb's Bridge.routes utility to find all routes between tokens.

Get All Routes

Retrieve all supported routes:

import { Bridge } from "thirdweb";
const routes = await Bridge.routes({
client,
});

This returns an array of route objects with information about supported token pairs:

[
{
destinationToken: {
address: "0x12c88a3C30A7AaBC1dd7f2c08a97145F5DCcD830",
chainId: 1,
decimals: 18,
iconUri:
"https://assets.coingecko.com/coins/images/37207/standard/G.jpg",
name: "G7",
symbol: "G7",
},
originToken: {
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
chainId: 480,
decimals: 18,
iconUri: "https://assets.relay.link/icons/1/light.png",
name: "Ether",
symbol: "ETH",
},
},
// ... more routes
];

Filter Routes by Origin

Get all routes starting from a specific chain and token:

import { Bridge } from "thirdweb";
// Get all routes starting from mainnet ETH
const routes = await Bridge.routes({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
client,
});

Filter Routes by Destination

Find routes that end at a specific destination:

import { Bridge } from "thirdweb";
// Get all routes ending at USDC on Optimism
const routes = await Bridge.routes({
destinationChainId: 10,
destinationTokenAddress:
"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
client,
});

Filter Routes by Both Origin and Destination

Find direct routes between specific token pairs:

import { Bridge } from "thirdweb";
// Get routes from mainnet ETH to USDC on Optimism
const routes = await Bridge.routes({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
destinationChainId: 10,
destinationTokenAddress:
"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",
client,
});

For large result sets, use pagination to retrieve routes in chunks:

import { Bridge } from "thirdweb";
// Get the first 10 routes starting from mainnet ETH
const routes = await Bridge.routes({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
limit: 10,
offset: 0,
client,
});
// Get the next 10 routes
const nextRoutes = await Bridge.routes({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
limit: 10,
offset: 10,
client,
});

Limit Route Complexity

Control the maximum number of steps in the returned routes:

import { Bridge } from "thirdweb";
// Get only direct routes (1 step)
const directRoutes = await Bridge.routes({
originChainId: 1,
originTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
maxSteps: 1,
client,
});

Going further

To connect with other auth strategies, use external wallets, or sponsor gas for users, check out the following guides:

Explore Full API References