跳转到主要内容
简而言之
提款 API 允许您从主钱包或子地址向任何外部地址发送稳定币。支持单笔和批量提款、网络费用估算,以及用于自定义托管流程的仅签名模式。

前提条件

1

API 密钥

Blockradar 控制台 获取您的 API 密钥。
2

有余额的钱包

确保您的钱包有足够的目标资产余额,以及支付 Gas 费用所需的原生代币。
3

资产 ID

GET /v1/wallets/{walletId}/assets 获取钱包专属的 assetId

主钱包 vs 子地址

主钱包

直接从主钱包提款。适合财务操作和出账支付。

子地址

从单个用户地址提款。适合结算特定用户的资金。

端点

操作主钱包子地址
网络费用POST /v1/wallets/{walletId}/withdraw/network-feePOST /v1/wallets/{walletId}/addresses/{addressId}/withdraw/network-fee
提款POST /v1/wallets/{walletId}/withdrawPOST /v1/wallets/{walletId}/addresses/{addressId}/withdraw

第一步:估算网络费用

const fee = await fetch(
  `https://api.blockradar.co/v1/wallets/${walletId}/withdraw/network-fee`,
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey },
    body: JSON.stringify({
      assetId: 'asset_usdc_base_mainnet',
      amount: '100',
      recipientAddress: '0x外部目标地址'
    })
  }
).then(r => r.json());

第二步:执行提款

const withdrawal = await fetch(
  `https://api.blockradar.co/v1/wallets/${walletId}/withdraw`,
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey },
    body: JSON.stringify({
      assetId: 'asset_usdc_base_mainnet',
      amount: '100',
      recipientAddress: '0x外部目标地址',
      reference: '支付-123',
      metadata: { userId: '用户_abc' }
    })
  }
).then(r => r.json());

Webhook 事件

事件描述
withdrawal.success提款已在链上确认
withdrawal.failed提款失败

API 参考

端点描述
网络费用 - 主钱包从主钱包估算 Gas
提款 - 主钱包从主钱包执行提款
网络费用 - 子地址从子地址估算 Gas
提款 - 子地址从子地址执行提款