跨链桥接 bridge

跨链桥接技能允许用户通过Wormhole和Circle CCTP协议在不同区块链之间转移代币。关键词包括:跨链技术、代币转移、Wormhole协议、CCTP协议、区块链交互。

跨链技术 0 次安装 0 次浏览 更新于 3/5/2026

bridge 跨链代币转移使用Wormhole和CCTP 桥接 - 完整的API参考

转移代币使用Wormhole和Circle CCTP协议。

支持的链

Wormhole CCTP (USDC)
Solana
Ethereum
Polygon
Arbitrum
Optimism
Avalanche
Base

聊天命令

报价

/bridge quote 100 USDC sol to eth           # 报价100 USDC Solana → Ethereum
/bridge quote 1000 USDC arb to base         # Arbitrum → Base
/bridge quote 50 USDC eth to sol            # 报价Ethereum → Solana

执行转移

/bridge send 100 USDC sol to eth            # 发送100 USDC Solana → Ethereum
/bridge send 1000 USDC arb to base          # 发送Arbitrum → Base
/bridge send 50 USDC eth to sol --address <dest>  # 到特定地址

赎回(认领)

/bridge redeem <tx-hash>                    # 认领转移的代币
/bridge pending                             # 列出待认领

状态

/bridge status <tx-hash>                    # 检查转移状态
/bridge history                             # 查看转移历史

TypeScript API参考

Wormhole桥

import { executeWormholeBridge, executeWormholeRedeem } from 'clodds/bridge/wormhole';

// 获取报价
const quote = await getWormholeQuote({
  sourceChain: 'solana',
  destChain: 'ethereum',
  token: 'USDC',
  amount: 100,
});

console.log(`转移100 USDC: Solana → Ethereum`);
console.log(`费用: $${quote.fee}`);
console.log(`预计时间: ${quote.estimatedTime} 秒`);

// 执行转移
const transfer = await executeWormholeBridge({
  sourceChain: 'solana',
  destChain: 'ethereum',
  token: 'USDC',
  amount: 100,

  // 源钱包
  sourcePrivateKey: process.env.SOLANA_PRIVATE_KEY,

  // 目的地地址(可选,默认为您的地址)
  destAddress: '0x1234...',
});

console.log(`转移启动: ${transfer.txHash}`);
console.log(`VAA: ${transfer.vaa}`);
console.log(`状态: ${transfer.status}`);

// 在目的地链上认领
const redeem = await executeWormholeRedeem({
  destChain: 'ethereum',
  vaa: transfer.vaa,
  destPrivateKey: process.env.EVM_PRIVATE_KEY,
});

console.log(`已认领: ${redeem.txHash}`);
console.log(`收到的金额: ${redeem.amount} USDC`);

CCTP(Circle)桥

import { executeCCTPBridge, redeemCCTP } from 'clodds/bridge/cctp';

// CCTP针对USDC转移优化
const transfer = await executeCCTPBridge({
  sourceChain: 'arbitrum',
  destChain: 'base',
  amount: 1000,  // USDC

  sourcePrivateKey: process.env.EVM_PRIVATE_KEY,
  destAddress: '0x1234...',
});

console.log(`CCTP转移: ${transfer.txHash}`);
console.log(`消息: ${transfer.messageHash}`);

// 等待认证(通常约15分钟)
await waitForAttestation(transfer.messageHash);

// 认领
const redeem = await redeemCCTP({
  destChain: 'base',
  messageHash: transfer.messageHash,
  destPrivateKey: process.env.EVM_PRIVATE_KEY,
});

检查状态

import { getTransferStatus } from 'clodds/bridge';

const status = await getTransferStatus(txHash);

console.log(`状态: ${status.status}`);
// 'pending' | 'confirming' | 'attesting' | 'redeemable' | 'completed' | 'failed'

console.log(`源确认: ${status.sourceConfirmations}`);
console.log(`VAA状态: ${status.vaaStatus}`);
console.log(`已认领: ${status.redeemed}`);

if (status.status === 'redeemable') {
  console.log(`准备认领! VAA: ${status.vaa}`);
}

获取待认领

import { getPendingRedemptions } from 'clodds/bridge';

const pending = await getPendingRedemptions({
  chains: ['ethereum', 'solana', 'arbitrum'],
  address: myAddress,
});

for (const p of pending) {
  console.log(`${p.sourceChain} → ${p.destChain}`);
  console.log(`  金额: ${p.amount} ${p.token}`);
  console.log(`  状态: ${p.status}`);
  console.log(`  年龄: ${p.age} 分钟`);
}

转移流程

Wormhole

  1. 锁定代币在源链
  2. 等待确认(因链而异)
  3. 守护者认证(VAA生成)
  4. 在目的地链上认领

CCTP

  1. 在源链上燃烧USDC
  2. 等待认证(约15分钟)
  3. 在目的地链上铸造USDC

费用和时间

路线 费用 时间
Solana → Ethereum ~$5 15-20 分钟
Ethereum → Solana ~$20 15-20 分钟
Arbitrum → Base (CCTP) ~$0.50 15-20 分钟
Polygon → Arbitrum ~$1 15-20 分钟

最佳实践

  1. 使用CCTP进行USDC - 更快更便宜
  2. 检查汽油价格 - 高汽油价格会增加成本
  3. 保存VAA/消息哈希 - 认领时需要
  4. 监控待转移 - 不要忘记认领
  5. 从小额开始 - 大额转移前先测试
  6. 验证目的地地址 - 发送前再次检查