Bridge USD₮0 EVM API Reference
Complete API documentation for @tetherto/wdk-protocol-bridge-usdt0-evm
Table of Contents
| Class | Description | Methods |
|---|---|---|
| Usdt0ProtocolEvm | Main class for bridging USD₮0 tokens across blockchains. Extends BridgeProtocol from @tetherto/wdk-wallet/protocols. | Constructor, Methods |
Usdt0ProtocolEvm
The main class for bridging USD₮0 tokens across different blockchains using the LayerZero protocol.
Extends BridgeProtocol from @tetherto/wdk-wallet/protocols.
Constructor
new Usdt0ProtocolEvm(account, config?)Parameters:
account(WalletAccountEvm | WalletAccountEvmErc4337 | WalletAccountReadOnlyEvm | WalletAccountReadOnlyEvmErc4337): The wallet account to use for bridge operationsconfig(BridgeProtocolConfig, optional): Configuration objectbridgeMaxFee(bigint, optional): Maximum total bridge cost in wei
Example:
import Usdt0ProtocolEvm from '@tetherto/wdk-protocol-bridge-usdt0-evm'
import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
const account = new WalletAccountEvm(seedPhrase, {
provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key'
})
const bridgeProtocol = new Usdt0ProtocolEvm(account, {
bridgeMaxFee: 1000000000000000n
})Methods
| Method | Description | Returns | Throws |
|---|---|---|---|
bridge(options, config?) | Bridges tokens to another blockchain | Promise<BridgeResult> | If no provider or fee exceeds max |
quoteBridge(options, config?) | Estimates the cost of a bridge operation | Promise<Omit<BridgeResult, 'hash' | 'approveHash'>> | If no provider |
bridge(options, config?)
Bridges tokens to a different blockchain using the USD₮0 protocol.
Parameters:
options(BridgeOptions): Bridge operation optionstargetChain(string): Destination chain namerecipient(string): Address that will receive the bridged tokenstoken(string): Token contract address on source chainamount(bigint): Amount to bridge in token base unitsoftContractAddress(string, optional): Override the default OFT contract addressdstEid(number, optional): Override the default LayerZero destination endpoint ID
config(Pick<EvmErc4337WalletConfig, 'paymasterToken'> & Pick<BridgeProtocolConfig, 'bridgeMaxFee'>, optional): Override configuration for ERC-4337 accountspaymasterToken(string, optional): Token to use for paying gas feesbridgeMaxFee(bigint, optional): Override maximum bridge fee
Returns: Promise<BridgeResult> - Bridge operation result
Throws:
- Error if account is read-only
- Error if no provider is configured
- Error if bridge fee exceeds maximum allowed
Example:
// Standard EVM account
const result = await bridgeProtocol.bridge({
targetChain: 'arbitrum',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
})
console.log('Bridge hash:', result.hash)
console.log('Approve hash:', result.approveHash)
console.log('Reset allowance hash:', result.resetAllowanceHash)
console.log('Total fee:', result.fee)
console.log('Bridge fee:', result.bridgeFee)
// ERC-4337 account
const result2 = await bridgeProtocol.bridge({
targetChain: 'arbitrum',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
}, {
paymasterToken: '0x...',
bridgeMaxFee: 1000000000000000n
})
console.log('Bridge hash:', result2.hash)
console.log('Total fee:', result2.fee)
console.log('Bridge fee:', result2.bridgeFee)
// Non-EVM destination with overrides
const result3 = await bridgeProtocol.bridge({
targetChain: 'solana',
recipient: 'SolanaRecipientAddress...',
token: '0x...',
amount: 1000000000000000000n,
oftContractAddress: '0x...',
dstEid: 30168
})quoteBridge(options, config?)
Estimates the cost of a bridge operation without executing it.
Parameters:
options(BridgeOptions): Bridge operation options (same as bridge method)config(Pick<EvmErc4337WalletConfig, 'paymasterToken'>, optional): Override configuration for ERC-4337 accountspaymasterToken(string, optional): Token to use for paying gas fees
Returns: Promise<Omit<BridgeResult, 'hash' | 'approveHash'>> - Bridge cost estimate
Throws: Error if no provider is configured
Example:
const quote = await bridgeProtocol.quoteBridge({
targetChain: 'polygon',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
})
console.log('Estimated fee:', quote.fee, 'wei')
console.log('Bridge fee:', quote.bridgeFee, 'wei')
if (quote.fee + quote.bridgeFee > 1000000000000000n) {
console.log('Bridge fees too high')
} else {
const result = await bridgeProtocol.bridge({
targetChain: 'polygon',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
})
}Types
BridgeOptions
interface BridgeOptions {
targetChain: string;
recipient: string;
token: string;
amount: bigint;
oftContractAddress?: string; // Override OFT contract address
dstEid?: number; // Override LayerZero destination endpoint ID
}BridgeResult
interface BridgeResult {
hash: string;
fee: bigint;
bridgeFee: bigint;
approveHash?: string;
resetAllowanceHash?: string;
}BridgeProtocolConfig
interface BridgeProtocolConfig {
bridgeMaxFee?: bigint;
}EvmErc4337WalletConfig
interface EvmErc4337WalletConfig {
paymasterToken?: string;
}Supported Chains
The bridge protocol supports the following chains:
Source Chains (EVM):
| Chain | Chain ID |
|---|---|
| Ethereum | 1 |
| Arbitrum | 42161 |
| Optimism | 10 |
| Polygon | 137 |
| Berachain | 80094 |
| Ink | 57073 |
| Plasma | 9745 |
| Conflux eSpace | 1030 |
| Corn | 21000000 |
| Avalanche | 43114 |
| Celo | 42220 |
| Flare | 14 |
| HyperEVM | 999 |
| Mantle | 5000 |
| MegaETH | 4326 |
| Monad | 143 |
| Morph | 2818 |
| Rootstock | 30 |
| Sei | 1329 |
| Stable | 988 |
| Unichain | 130 |
| XLayer | 196 |
Destination Chains:
All source chains above, plus:
| Chain | Endpoint ID (EID) |
|---|---|
| Solana | 30168 |
| TON | 30343 |
| TRON | 30420 |
Error Handling
The bridge protocol throws specific errors for different failure cases:
try {
const result = await bridgeProtocol.bridge({
targetChain: 'arbitrum',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
})
} catch (error) {
if (error.message.includes('not supported')) {
console.error('Chain or token not supported')
}
if (error.message.includes('Exceeded maximum fee')) {
console.error('Bridge fee too high')
}
if (error.message.includes('must be connected to a provider')) {
console.error('Wallet not connected to blockchain')
}
if (error.message.includes('requires the protocol to be initialized with a non read-only account')) {
console.error('Cannot bridge with read-only account')
}
if (error.message.includes('cannot be equal to the source chain')) {
console.error('Cannot bridge to the same chain')
}
}Usage Examples
Basic Bridge Operation
import Usdt0ProtocolEvm from '@tetherto/wdk-protocol-bridge-usdt0-evm'
import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'
async function bridgeTokens() {
const account = new WalletAccountEvm(seedPhrase, {
provider: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key'
})
const bridgeProtocol = new Usdt0ProtocolEvm(account, {
bridgeMaxFee: 1000000000000000n
})
const quote = await bridgeProtocol.quoteBridge({
targetChain: 'arbitrum',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
})
console.log('Bridge quote:', quote)
const result = await bridgeProtocol.bridge({
targetChain: 'arbitrum',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
})
console.log('Bridge result:', result)
return result
}Multi-Chain Bridge
async function bridgeToMultipleChains(bridgeProtocol) {
const chains = ['arbitrum', 'polygon', 'ethereum']
const token = '0x...'
const amount = 1000000000000000000n
const recipient = '0x...'
const results = []
for (const chain of chains) {
try {
const quote = await bridgeProtocol.quoteBridge({
targetChain: chain,
recipient,
token,
amount
})
console.log(`Bridge to ${chain}:`, quote)
const result = await bridgeProtocol.bridge({
targetChain: chain,
recipient,
token,
amount
})
results.push({ chain, result })
console.log(`Bridge to ${chain} successful:`, result.hash)
} catch (error) {
console.error(`Bridge to ${chain} failed:`, error.message)
}
}
return results
}ERC-4337 Gasless Bridge
import { WalletAccountEvmErc4337 } from '@tetherto/wdk-wallet-evm-erc-4337'
async function gaslessBridge() {
const account = new WalletAccountEvmErc4337(seedPhrase, {
provider: 'https://arb1.arbitrum.io/rpc',
paymasterToken: '0x...'
})
const bridgeProtocol = new Usdt0ProtocolEvm(account, {
bridgeMaxFee: 1000000000000000n
})
const result = await bridgeProtocol.bridge({
targetChain: 'polygon',
recipient: '0x...',
token: '0x...',
amount: 1000000000000000000n
}, {
paymasterToken: '0x...'
})
console.log('Gasless bridge result:', result)
return result
}Node.js Quickstart
Get started with WDK in a Node.js environment
Configuration
Configure the Bridge USD₮0 EVM Protocol
Usage
Installation, quick start, and usage examples