WDK logoWDK documentation

Bridge USD₮0 EVM API Reference

Complete API documentation for @tetherto/wdk-protocol-bridge-usdt0-evm

Table of Contents

ClassDescriptionMethods
Usdt0ProtocolEvmMain 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 operations
  • config (BridgeProtocolConfig, optional): Configuration object
    • bridgeMaxFee (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

MethodDescriptionReturnsThrows
bridge(options, config?)Bridges tokens to another blockchainPromise<BridgeResult>If no provider or fee exceeds max
quoteBridge(options, config?)Estimates the cost of a bridge operationPromise<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 options
    • targetChain (string): Destination chain name
    • recipient (string): Address that will receive the bridged tokens
    • token (string): Token contract address on source chain
    • amount (bigint): Amount to bridge in token base units
    • oftContractAddress (string, optional): Override the default OFT contract address
    • dstEid (number, optional): Override the default LayerZero destination endpoint ID
  • config (Pick<EvmErc4337WalletConfig, 'paymasterToken'> & Pick<BridgeProtocolConfig, 'bridgeMaxFee'>, optional): Override configuration for ERC-4337 accounts
    • paymasterToken (string, optional): Token to use for paying gas fees
    • bridgeMaxFee (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 accounts
    • paymasterToken (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):

ChainChain ID
Ethereum1
Arbitrum42161
Optimism10
Polygon137
Berachain80094
Ink57073
Plasma9745
Conflux eSpace1030
Corn21000000
Avalanche43114
Celo42220
Flare14
HyperEVM999
Mantle5000
MegaETH4326
Monad143
Morph2818
Rootstock30
Sei1329
Stable988
Unichain130
XLayer196

Destination Chains:

All source chains above, plus:

ChainEndpoint ID (EID)
Solana30168
TON30343
TRON30420

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
}

Need Help?

On this page