bridge(params)
Use the bridge
function to bridge tokens from one chain to another.
Parameters
Typescript
interface BridgeParams {
token: SUPPORTED_TOKENS;
amount: number | string;
chainId: SUPPORTED_CHAINS_IDS;
gas?: bigint;
}
Bridge Example
⚠️
Please go through the overview page to understand how to set up the SDK and the required hooks before using any SDK function that moves around user funds.
Here are some minimal examples of how to use the bridge
function:
Typescript
// Simple bridge operation
await sdk.bridge({
token: 'USDC',
amount: 100, // 100 USDC
chainId: 137, // to Polygon
});
// Bridge with custom gas limit
await sdk.bridge({
token: 'ETH',
amount: '0.5', // 0.5 ETH as string
chainId: 42161, // to Arbitrum
gas: 100000n, // custom gas limit
});
// Bridge from string amounts
await sdk.bridge({
token: 'USDT',
amount: '1000.50', // precise amount as string
chainId: 10, // to Optimism
});
Return Value
Typescript
interface BridgeResult {
success: boolean;
error?: string;
explorerUrl?: string;
}
ADVANCED EXAMPLES
- You can also use the
bridgeSimulation
function to sanity check your bridge intent before executing it. You can go through the docs here - For a complete example on how to set up hooks and handle errors, you can go through the docs here
Last updated on