Enable Bulk ERC20 Withdrawals - cURL

Approve the batcher smart contract to enable bulk ERC20 token withdrawals using the REST API. Includes flows for Custody MPC, Custody Multisig, Self-Custody MPC, BitGo Offline Vault MPC, Self-Custody Multisig, and BitGo Offline Vault Multisig wallets. See the Guide.

  1. Before approving tokens, you can check if your wallet has already approved the batcher contract. The large number shown in the response (2^256-1) is the maximum approval amount (unlimited).

    Approving the batcher smart contract is a one-time operation, but each token requires a separate approval in each wallet.

    Prerequisites: Complete Get Started, Create Wallets, and Deposit Assets (you must have the ERC20 token in the wallet).

    API Reference

  2. Build an approval transaction for the ERC20 token to authorize the batcher smart contract to transfer tokens on your behalf. The request body depends on your wallet type:

    • Custody MPC and Self-Custody MPC/BitGo Offline Vault MPC: Use the intent.intentType: "tokenApproval" body. self-custody MPC variants also require feeOptions.
    • Custody Multisig: Use a flat body with type: "tokenApproval" and tokenName.
    • Self-Custody Multisig/BitGo Offline Vault Multisig: Use a minimal body with just tokenName.

    Transactions for approving the batcher smart contract follow the transaction flow of the wallet type, and must receive all required signatures and approvals before broadcasting to the blockchain. Once your approval transaction has all signatures and broadcasts, you can Bulk Withdraw ERC20 Tokens.

    API Reference

// 1. (Optional) Check Token Allowance
export COIN="<ASSET_ID_OF_NATIVE_COIN>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"

curl -X GET \
  https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/allowance \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN"

// 2. Approve Batcher Smart Contract
export COIN="<ASSET_ID_OF_NATIVE_COIN>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export TOKEN_NAME="<ASSET_ID_OF_TOKEN>"

curl -X POST \
  https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/token/approval/build \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "intent": {
      "intentType": "tokenApproval",
      "tokenName": "'"$TOKEN_NAME"'"
    }
  }'
Response
// 1. (Optional) Check Token Allowance Response
{
  "allowance": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
}

// Approve Batcher Smart Contract Response (applies to all wallet types)
{
  "pendingApproval": {
    "id": "63727a81cdbc820007b27caa7b76016d",
    "coin": "eth",
    "wallet": "63726fde0a3c94000758f2790536041d",
    "state": "pendingFinalApproval",
    "scope": "wallet",
    "info": {
      "type": "transactionRequest",
      "transactionRequest": {
        "coinSpecific": {
          "eth": {
            "eip1559": {
              "maxPriorityFeePerGas": 1500000000,
              "maxFeePerGas": 133302263906
            },
            "recipients": [
              {
                "amount": "0",
                "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
                "data": "0x095ea7b3000000000000000000000000..."
              }
            ]
          }
        }
      }
    }
  }
}