bridge()
SET UP THE SDK BEFORE YOU START:
You can find the SDK setup instructions in the Overview page.
Use the bridge()
function to bridge tokens between chains across all supported networks.
Parameters
Typescript
/**
* Parameters for bridging tokens.
*/
export interface BridgeParams {
token: SUPPORTED_TOKENS;
amount: number | string;
chainId: SUPPORTED_CHAINS_IDS;
gas?: bigint;
}
Example
Typescript
import type { BridgeParams, BridgeResult, SimulationResult } from '@avail-project/nexus';
// Bridge tokens between chains
const result: BridgeResult = await sdk.bridge({
token: 'USDC',
amount: 100,
chainId: 137,
} as BridgeParams);
// Simulate bridge to preview costs
const simulation: SimulationResult = await sdk.simulateBridge({
token: 'USDC',
amount: 100,
chainId: 137,
});
Return Value
Typescript
/**
* Result structure for bridge transactions.
*/
export interface BridgeResult {
success: boolean;
error?: string;
explorerUrl?: string;
transactionHash?: string; // Add transaction hash property
}
Last updated on