Bulk Withdrawal ERC20 Tokens - Multisig
Send multiple ERC20 token transfers in a single transaction using a multisig wallet. See the Guide.
-
Build a bulk withdrawal transaction by providing multiple recipients in your transaction request, each specifying the recipient address and amount. The SDK consolidates the recipients array into a single transaction that interacts with the batcher contract. The contract then distributes the tokens to each recipient address according to the specified amounts.
All transfers in a batch must use the same token type. Maximum batch size varies by network (typically around 100 recipients per transaction).
Prerequisites: Complete Get Started and Create Wallets. Also complete Deposit Assets and Enable Bulk Withdrawals of ERC20 Tokens. Ensure you have sufficient balance of the native coin to cover gas fees.
-
After building the transaction, sign it and send it to BitGo for processing. For multisig wallets, you can use
sendManyto build, sign, and send in one operation. Provide the same recipients array, the token name, and your wallet passphrase.
// 1. Build a Bulk Withdrawal Transaction
// Use the JavaScript SDK for this step (see JavaScript tab)
// 2. Sign and Send Transaction
// Use the JavaScript SDK for this step (see JavaScript tab)
// 1. Build a Bulk Withdrawal Transaction
async function buildBulkTokenWithdrawal() {
const walletInstance = await bitgo
.coin('opeth')
.wallets()
.get({ id: '<YOUR_WALLET_ID>' });
// Build a transaction with multiple recipients
const buildResult = await walletInstance.prebuildTransaction({
recipients: [
{
address: '0x1111111111111111111111111111111111111111',
amount: '100000000'
},
{
address: '0x2222222222222222222222222222222222222222',
amount: '200000000'
},
{
address: '0x3333333333333333333333333333333333333333',
amount: '300000000'
}
],
tokenName: 'opeth:usdc'
});
return buildResult;
}
// 2. Sign and Send Transaction
async function sendBulkTokenWithdrawal() {
const walletInstance = await bitgo
.coin('opeth')
.wallets()
.get({ id: '<YOUR_WALLET_ID>' });
// Build, sign and send in one operation
const result = await walletInstance.sendMany({
recipients: [
{
address: '0x1111111111111111111111111111111111111111',
amount: '100000000'
},
{
address: '0x2222222222222222222222222222222222222222',
amount: '200000000'
},
{
address: '0x3333333333333333333333333333333333333333',
amount: '300000000'
}
],
tokenName: 'opeth:usdc',
walletPassphrase: 'VerySecurePassword1234',
});
return result;
}
// 2. Sign and Send Transaction Response
{
"transfer": {
"coin": "opeth:usdc",
"id": "63727a81cdbc820007b27caa7b76016d",
"wallet": "63726fde0a3c94000758f2790536041d",
"txid": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"height": 0,
"date": "2023-11-14T17:27:29.128Z",
"type": "send",
"value": "-600000000",
"valueString": "-600000000",
"baseValueString": "-600000000",
"baseValueWithoutFeesString": "-600000000",
"feeString": "0",
"payGoFee": 0,
"payGoFeeString": "0",
"state": "signed",
"instant": false
},
"txid": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"status": "signed"
}