Purpose
This skill enables Claude to help users bridge assets across different blockchain networks using various bridge protocols.
Security Warnings
CRITICAL - BRIDGING IS HIGH-RISK:
- ALWAYS verify bridge contract addresses from official sources
- ALWAYS start with small test amounts
- ALWAYS check bridge fees and slippage
- WARN about potential delays (minutes to hours)
- NEVER rush - scam bridges are common
- RECOMMEND using official/audited bridges only
Supported Bridge Protocols
| Protocol | Networks | Type |
|---|---|---|
| Stargate | ETH, BSC, Polygon, Arbitrum, Optimism | Liquidity Bridge |
| LayerZero OFT | Multiple EVM chains | Token Bridge |
| Chainlink CCIP | ETH, Polygon, Arbitrum, Optimism, BSC | Cross-Chain |
| BSC Bridge | Ethereum ↔ BSC | Native Bridge |
| Polygon Bridge | Ethereum ↔ Polygon | Native Bridge |
| Arbitrum Bridge | Ethereum ↔ Arbitrum | Native Bridge |
Quick Start
Stargate Bridge Example
import { createWalletClient, createPublicClient, http, parseUnits } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet, bsc } from 'viem/chains'
// Stargate Router ABI (simplified)
const STARGATE_ROUTER_ABI = [
{
name: 'swap',
type: 'function',
inputs: [
{ name: '_dstChainId', type: 'uint16' },
{ name: '_srcPoolId', type: 'uint256' },
{ name: '_dstPoolId', type: 'uint256' },
{ name: '_refundAddress', type: 'address' },
{ name: '_amountLD', type: 'uint256' },
{ name: '_minAmountLD', type: 'uint256' },
{ name: '_lzTxParams', type: 'tuple' },
{ name: '_to', type: 'bytes' },
{ name: '_payload', type: 'bytes' }
],
outputs: [],
stateMutability: 'payable'
},
{
name: 'quoteLayerZeroFee',
type: 'function',
inputs: [
{ name: '_dstChainId', type: 'uint16' },
{ name: '_functionType', type: 'uint8' },
{ name: '_toAddress', type: 'bytes' },
{ name: '_transferAndCallPayload', type: 'bytes' },
{ name: '_lzTxParams', type: 'tuple' }
],
outputs: [
{ name: 'nativeFee', type: 'uint256' },
{ name: 'zroFee', type: 'uint256' }
]
}
]
// Stargate Chain IDs
const STARGATE_CHAIN_IDS = {
ethereum: 101,
bsc: 102,
avalanche: 106,
polygon: 109,
arbitrum: 110,
optimism: 111
}
// Stargate Pool IDs
const POOL_IDS = {
USDC: 1,
USDT: 2,
ETH: 13
}
// Stargate Router addresses
const STARGATE_ROUTERS = {
ethereum: '0x8731d54E9D02c286767d56ac03e8037C07e01e98',
bsc: '0x4a364f8c717cAAD9A442737Eb7b8A55cc6cf18D8',
polygon: '0x45A01E4e04F14f7A4a6702c74187c5F6222033cd',
arbitrum: '0x53Bf833A5d6c4ddA888F69c22C88C9f356a41614'
}
Get Bridge Quote
import { createPublicClient, http, parseUnits, formatUnits, formatEther } from 'viem'
import { mainnet } from 'viem/chains'
const publicClient = createPublicClient({
chain: mainnet,
transport: http()
})
// Get fee estimate for bridging USDC from Ethereum to BSC
const lzTxParams = {
dstGasForCall: 0n,
dstNativeAmount: 0n,
dstNativeAddr: '0x'
}
const [nativeFee, zroFee] = await publicClient.readContract({
address: STARGATE_ROUTERS.ethereum,
abi: STARGATE_ROUTER_ABI,
functionName: 'quoteLayerZeroFee',
args: [
STARGATE_CHAIN_IDS.bsc, // Destination chain
1, // Function type (swap)
'0x0000000000000000000000000000000000000000', // Destination address as bytes
'0x', // Payload
lzTxParams
]
})
console.log('Bridge fee:', formatEther(nativeFee), 'ETH')
Execute Bridge Transfer
import { createWalletClient, http, parseUnits, encodePacked } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
const account = privateKeyToAccount('0x...')
const walletClient = createWalletClient({
account,
chain: mainnet,
transport: http()
})
// Bridge 100 USDC from Ethereum to BSC
const amount = parseUnits('100', 6) // USDC has 6 decimals
const minAmount = parseUnits('99', 6) // 1% slippage
const destinationAddress = encodePacked(['address'], [account.address])
const lzTxParams = {
dstGasForCall: 0n,
dstNativeAmount: 0n,
dstNativeAddr: '0x'
}
// First approve USDC to Stargate Router
// ... (approval code)
// Then execute bridge
const hash = await walletClient.writeContract({
address: STARGATE_ROUTERS.ethereum,
abi: STARGATE_ROUTER_ABI,
functionName: 'swap',
args: [
STARGATE_CHAIN_IDS.bsc, // Destination chain
POOL_IDS.USDC, // Source pool
POOL_IDS.USDC, // Destination pool
account.address, // Refund address
amount, // Amount to bridge
minAmount, // Minimum amount to receive
lzTxParams,
destinationAddress, // Recipient on destination chain
'0x' // Additional payload
],
value: nativeFee // Pay LayerZero fee in native token
})
console.log('Bridge transaction:', hash)
Common Operations
1. Check Bridge Status
Most bridges provide APIs to track transaction status:
// Stargate/LayerZero tracking
// Use LayerZero Scan: https://layerzeroscan.com/tx/{txHash}
// Generic transaction check
async function checkBridgeStatus(
sourceChainClient: any,
txHash: string
) {
// Check source chain confirmation
const receipt = await sourceChainClient.getTransactionReceipt({
hash: txHash
})
if (receipt.status === 'success') {
console.log('Source chain confirmed!')
console.log('Waiting for destination chain...')
console.log('Track at: https://layerzeroscan.com/tx/' + txHash)
}
return receipt
}
2. Estimate Bridge Time
| Bridge | Typical Time | Notes |
|---|---|---|
| Stargate | 1-5 minutes | Fast with liquidity |
| LayerZero OFT | 1-5 minutes | Fast for supported tokens |
| CCIP | 5-30 minutes | Security-focused |
| BSC Bridge | 10-30 minutes | Native bridge |
| Polygon Bridge | 10-30 minutes (to) / 7 days (from) | PoS bridge |
| Arbitrum Bridge | ~10 minutes (to) / 7 days (from) | Optimistic rollup |
3. Native Bridge Example (Arbitrum)
import { createWalletClient, http, parseEther } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'
// Arbitrum Delayed Inbox (for ETH deposits)
const ARBITRUM_INBOX = '0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f'
const INBOX_ABI = [
{
name: 'depositEth',
type: 'function',
inputs: [],
outputs: [{ name: '', type: 'uint256' }],
stateMutability: 'payable'
}
]
const account = privateKeyToAccount('0x...')
const walletClient = createWalletClient({
account,
chain: mainnet,
transport: http()
})
// Bridge ETH to Arbitrum
const hash = await walletClient.writeContract({
address: ARBITRUM_INBOX,
abi: INBOX_ABI,
functionName: 'depositEth',
value: parseEther('0.1') // 0.1 ETH
})
console.log('Bridge initiated:', hash)
console.log('Funds will arrive on Arbitrum in ~10 minutes')
4. Compare Bridge Fees
async function compareBridgeFees(
amount: bigint,
fromChain: string,
toChain: string
) {
const fees = []
// Get Stargate fee
try {
const stargateFee = await getStargateFee(amount, fromChain, toChain)
fees.push({ bridge: 'Stargate', fee: stargateFee })
} catch (e) {
fees.push({ bridge: 'Stargate', fee: 'Not available' })
}
// Add other bridge fee checks...
// Sort by lowest fee
fees.sort((a, b) => {
if (typeof a.fee === 'string') return 1
if (typeof b.fee === 'string') return -1
return Number(a.fee - b.fee)
})
return fees
}
Bridge Workflow
When a user requests a bridge, follow this workflow:
Step 1: Gather Information
Please provide:
1. Source network (e.g., Ethereum)
2. Destination network (e.g., BNB Chain)
3. Token to bridge (e.g., USDC, USDT, ETH)
4. Amount to bridge
5. Destination address (if different from source)
Step 2: Research and Quote
🌉 Bridge Options
═══════════════════
From: Ethereum
To: BNB Smart Chain
Token: USDC
Amount: 100 USDC
Available Bridges:
1. Stargate (Recommended)
⏱️ Time: ~2-5 minutes
💰 Fee: ~$2.50 (0.001 ETH)
📦 Min Amount: 10 USDC
2. Official BSC Bridge
⏱️ Time: ~15-30 minutes
💰 Fee: ~$5.00 (gas only)
📦 Min Amount: None
⚠️ Note: Bridge times are estimates and may vary.
Step 3: Confirm and Warn
🔐 Bridge Confirmation
═══════════════════════
Route: Ethereum → BNB Chain via Stargate
Amount: 100 USDC
Expected: 99.75 USDC (after fees)
Fee: ~0.001 ETH (~$2.50)
⚠️ IMPORTANT WARNINGS:
1. Transactions CANNOT be reversed
2. Bridge may take 2-30 minutes
3. Keep some ETH for future transactions
4. Verify you can access your destination wallet
Have you verified the destination address?
Proceed with bridge? (yes/no)
Step 4: Execute and Track
✅ Bridge Initiated!
Source Transaction: 0x7a8b...c3d4
Network: Ethereum
Status: Confirmed ✓
⏳ Waiting for destination confirmation...
Track progress:
- LayerZero Scan: https://layerzeroscan.com/tx/0x7a8b...c3d4
- Etherscan: https://etherscan.io/tx/0x7a8b...c3d4
Expected arrival: ~5 minutes
Bridge Contract Addresses
Stargate Routers
| Network | Address |
|---|---|
| Ethereum | 0x8731d54E9D02c286767d56ac03e8037C07e01e98 |
| BSC | 0x4a364f8c717cAAD9A442737Eb7b8A55cc6cf18D8 |
| Polygon | 0x45A01E4e04F14f7A4a6702c74187c5F6222033cd |
| Arbitrum | 0x53Bf833A5d6c4ddA888F69c22C88C9f356a41614 |
| Optimism | 0xB0D502E938ed5f4df2E681fE6E419ff29631d62b |
Native Bridges
| Bridge | Address |
|---|---|
| Arbitrum Inbox | 0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f |
| Polygon RootChain | 0xA0c68C638235ee32657e8f720a23ceC1bFc77C77 |
| Optimism Portal | 0x49048044D57e1C92A77f79988d21Fa8fAF74E97e |
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
| Insufficient liquidity | Not enough tokens in pool | Try smaller amount or different route |
| Slippage exceeded | Price moved during tx | Increase slippage tolerance |
| Invalid destination | Wrong chain ID or address | Verify destination parameters |
| Fee too low | LayerZero fee insufficient | Use updated fee quote |
Example Error Handling
try {
const hash = await walletClient.writeContract({
// Bridge call...
})
console.log('Bridge initiated:', hash)
} catch (error) {
if (error.message.includes('INSUFFICIENT_LIQUIDITY')) {
console.log('Error: Not enough liquidity in the bridge pool')
console.log('Try:')
console.log('1. A smaller amount')
console.log('2. A different bridge')
console.log('3. Waiting for liquidity to replenish')
} else if (error.message.includes('LayerZero')) {
console.log('Error: LayerZero fee estimation failed')
console.log('Please get a fresh fee quote and try again')
} else {
console.log('Bridge failed:', error.message)
}
}
Security Checklist
Before any bridge operation:
- Verified bridge contract from official documentation
- Checked bridge protocol is audited
- Confirmed destination address is correct
- Tested with small amount first
- Understood fees and timing
- Have destination chain gas for future transactions
- Saved source transaction hash for tracking
Best Practices
- Always use official bridges - Avoid unknown third-party bridges
- Start small - Test with minimum amount first
- Keep gas - Ensure you have gas on destination chain
- Save hashes - Keep all transaction hashes for support
- Be patient - Bridges can be slow, don't panic
- Double-check addresses - Wrong chain = lost funds
- Monitor progress - Use block explorers to track