Consolidate Account Balance
Overview
A consolidation is a transaction that transfers assets from receive addresses to the base address of a wallet.
For account-based assets, the spendable balance of a wallet is the balance of the assets in the base address. The spendable balance is the total amount available for withdrawal. The confirmed balance is the balance of the base address plus all the receive addresses. If a wallet has multiple receive addresses, you can obtain the maximum withdrawal amount by consolidating the balances from the receive addresses to the base address.
Manual consolidations are required for account based assets that aren't on Ethereum Virtual Machine (EVM) blockchains. For EVM wallets, BitGo can enable automatic consolidations. To learn about automatic consolidations for EVM wallets, see Consolidations.
How it Works
Consolidations are a type of transaction request. A single consolidation request can consolidate multiple receive addresses. Most networks can consolidate up to 750 addresses per consolidation request.
Each receive address that's consolidated in a consolidation request creates a unique transaction. For example, if you consolidate a wallet with 10 receive addresses in a single consolidation request, BitGo creates 10 on-chain transactions.
Consolidations are also single asset transactions. If a wallet has a variety of assets in the receive addresses, you must consolidate each asset in a separate consolidation request.
Some blockchains require a minimum balance in a receive address. When you consolidate a wallet, the minimum balance remains in the receive addresses. This results in your spendable balance being slightly less than your confirmed balance.
Note: Solana stands out from other blockchains in how it handles consolidations. For Solana wallets, consolidations are limited to just 25 receive addresses per consolidation. However, Solana wallets are capable of consolidating up to eight different assets from a receive address in a consolidation request, significantly reducing transaction costs.
The fee for a consolidation transaction is paid by either the gas tank or the receive address. You can view the fee source for each asset in Consolidations. You can learn more about asset-specific requirements for consolidations in the Blockchain References.
Simple or Manual
Similar to withdrawing, consolidating has two different flows that you can use depending on your use case. The simple flow uses either Express or the the JavaScript SDK. In the simple flow, you build, sign, and send the the consolidation transaction all in 1 step. The manual flow uses either REST endpoints or the JavaScript SDK to build the consolidation transaction, and then sign and send it in separate calls.
This page documents both flows. Select the button below for the flow that works best for you:
Prerequisites
1. (Optional) Check Consolidation Requirements
Determine if your wallet requires consolidations.
Endpoint: Get Wallet by ID
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/wallet/$WALLET_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \Step Result
The response shows either "needsConsolidation": true or "needsConsolidation": false.
{
"allowBackupKeySigning": true,
"approvalsRequired": 1,
"coin": "tbtc4",
...
...
...
"needsConsolidation": true,
"tokenConsolidationState": null,
"tokenAddress": null
}2. Build, Sign, and Send Consolidation
Modify the following code to build, sing, and send a consolidation transaction, all in 1 step.
Endpoint: Consolidate Account (Simple)
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export WALLET_PASSPHRASE="<WALLET_PASSPHRASE>"
curl -X POST \
http://$BITGO_EXPRESS_HOST/api/v2/$COIN/wallet/$WALLET_ID/consolidateAccount \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"walletPassphrase": "'"$WALLET_PASSPHRASE"'"
}'const BitGoJS = require('bitgo');
const Promise = require('bluebird');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
const coin = 'talgo';
// Set your wallet id
const walletId = '';
// Set your wallet passphrase
const walletPassphrase = '';
// Set OTP code
const otp = '000000';
// Set your access token here
bitgo.authenticateWithAccessToken({ accessToken });
const wallet = await bitgo.coin(coin).wallets().get({ id: walletId });
// Wallet's base address - only address in the wallet that can send assets to other accounts
console.log('Base Address:', wallet.coinSpecific().baseAddress);
// Confirmed balance - sum of the balance of all the wallet's addresses
console.log('Confirmed Balance:', wallet.confirmedBalanceString());
// Spendable balance - balance of the base address
console.log('Spendable Balance:', wallet.spendableBalanceString());
// unlock the session for sending assets
const unlock = await bitgo.unlock({ otp, duration: 3600 });
if (!unlock) {
throw new Error('error unlocking session');
}
const consolidationTxes = await wallet.buildAccountConsolidations();
try {
for (const unsignedConsolidation of consolidationTxes) {
const res = await wallet.sendAccountConsolidation({ walletPassphrase, prebuildTx: unsignedConsolidation });
console.dir(res, { depth: 6 });
}
} catch (e) {
console.error(e);
}
);Step Result
If the transaction requires admin approval, it remains in a pending approval status until receiving final approval. If approval isn't required, you receive a calendar invitation by email to schedule video ID verification with a BitGo operator.
Your base address receives all available assets from the receive address, maximizing your spendable balance.
{
"success": [
{
"transfer": {
"entries": [
{
"address": "2MTMBrkZ8ufANXEspAygYidLdq23DuchgUbAnVhM5WJ2",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"value": -552864,
"valueString": "-552864"
},
{
"address": "goS1SabSeeAkSGYDTKAxAtxGDuhVhvdow9hzrAmSs7i",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"value": 547864,
"valueString": "547864"
}
],
"id": "664cb91bad992f4616883304a7fc0474",
"coin": "tsol",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"walletType": "hot",
"enterprise": "62c5ae8174ac860007aff138a2d74df7",
"txid": "3HQgnz8CvzY5nNGDZVgxWjP7iW6E4w2PiDJ5AmVWdrMpMCPYR2th8THrXNG8iRYn1uhqJBCcSusPKaduqizfbCDm",
"txidType": "transactionHash",
"txRequestId": "ea456e38-ed16-44dd-ae07-95ea2d11fc52",
"height": 999999999,
"heightId": "999999999-664cb91bad992f4616883304a7fc0474",
"date": "2024-05-21T15:09:15.345Z",
"type": "send",
"value": -5000,
"valueString": "-5000",
"intendedValueString": "-5000",
"baseValue": 0,
"baseValueString": "0",
"baseValueWithoutFees": 0,
"baseValueWithoutFeesString": "0",
"feeString": "5000",
"payGoFee": 0,
"payGoFeeString": "0",
"usd": -0.00088675,
"usdRate": 177.35,
"state": "signed",
"instant": false,
"isReward": false,
"isUnlock": false,
"isFee": false,
"tags": [
"663bd7b6f7d26f5528c280b7ef3f283c",
"62c5ae8174ac860007aff138a2d74df7"
],
"history": [
{
"date": "2024-05-21T15:09:15.385Z",
"action": "commented",
"comment": "Address balance consolidation"
},
{ "date": "2024-05-21T15:09:15.345Z", "action": "signed" },
{
"date": "2024-05-21T15:09:15.088Z",
"user": "62ab90e06dfda30007974f0a52a12995",
"action": "created"
}
],
"signedDate": "2024-05-21T15:09:15.345Z",
"comment": "Address balance consolidation",
"metadata": [],
"commentedTime": "2024-05-21T15:09:15.385Z",
"signedTime": "2024-05-21T15:09:15.345Z",
"createdTime": "2024-05-21T15:09:15.088Z",
"consolidateId": "664cb910334efb3022281f91c04ab1cd"
},
"txid": "3HQgnz8CvzY5nNGDZVgxWjP7iW6E4w2PiDJ5AmVWdrMpMCPYR2th8THrXNG8iRYn1uhqJBCcSusPKaduqizfbCDm",
"tx": "AXIvGBmFU1kcxtS2OYkgTyq6mNaNZXyBJbc2KXRk+IcTUnZ19AELipFAoTrXWQ+S4Z9R5IGi2SpTwYbtJ/9+dgABAAEDFBkYTpHBo1CjPmnPcBEV4prWe5qcrLJsnSPncQFFGE8KMibEyVdRKDQLyxt8RE+Dnc/cWvkd2t5kq17sfnYKlQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAw/V2CP68vtBg9DLRZD5VjyAGKE4p4UzeMdsSPuGMQBAgIAAQwCAAAAGFwIAAAAAAA=",
"status": "signed"
},
{
"transfer": {
"entries": [
{
"address": "2GqoXzwbrMzsihaBFJ7rqv2Wx97TZFoeYXGgtUXfB5rV",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"value": -552864,
"valueString": "-552864"
},
{
"address": "goS1SabSeeAkSGYDTKAxAtxGDuhVhvdow9hzrAmSs7i",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"value": 547864,
"valueString": "547864"
}
],
"id": "664cb925115835bc0705c77dcb9c31f3",
"coin": "tsol",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"walletType": "hot",
"enterprise": "62c5ae8174ac860007aff138a2d74df7",
"txid": "4jTuXye727WJmbxZbj2FGvmyMC7Eaz5QZJm4Ltne66ugt8ZpaH3EKmrisPccjWCpMhZ65tNAM2sq3MpxEeNyLtj7",
"txidType": "transactionHash",
"txRequestId": "fa888ab0-b77d-42a5-b739-deb5188e51fd",
"height": 999999999,
"heightId": "999999999-664cb925115835bc0705c77dcb9c31f3",
"date": "2024-05-21T15:09:25.508Z",
"type": "send",
"value": -5000,
"valueString": "-5000",
"intendedValueString": "-5000",
"baseValue": 0,
"baseValueString": "0",
"baseValueWithoutFees": 0,
"baseValueWithoutFeesString": "0",
"feeString": "5000",
"payGoFee": 0,
"payGoFeeString": "0",
"usd": -0.00088675,
"usdRate": 177.35,
"state": "signed",
"instant": false,
"isReward": false,
"isUnlock": false,
"isFee": false,
"tags": [
"663bd7b6f7d26f5528c280b7ef3f283c",
"62c5ae8174ac860007aff138a2d74df7"
],
"history": [
{
"date": "2024-05-21T15:09:25.538Z",
"action": "commented",
"comment": "Address balance consolidation"
},
{ "date": "2024-05-21T15:09:25.507Z", "action": "signed" },
{
"date": "2024-05-21T15:09:25.149Z",
"user": "62ab90e06dfda30007974f0a52a12995",
"action": "created"
}
],
"signedDate": "2024-05-21T15:09:25.507Z",
"comment": "Address balance consolidation",
"metadata": [],
"commentedTime": "2024-05-21T15:09:25.538Z",
"signedTime": "2024-05-21T15:09:25.507Z",
"createdTime": "2024-05-21T15:09:25.149Z",
"consolidateId": "664cb910334efb3022281f91c04ab1cd"
},
"txid": "4jTuXye727WJmbxZbj2FGvmyMC7Eaz5QZJm4Ltne66ugt8ZpaH3EKmrisPccjWCpMhZ65tNAM2sq3MpxEeNyLtj7",
"tx": "AbqrlR3L8qoQGDlUnooBjVXBLyRoLi9rXznrrYLLqN9CDVHhKt/YSxIhrze9ng+1azIQDVftZLwD+CawRjLKRw4BAAEDEuqUfC0SW8xbjWksisdw1dxfwRf14h9vSLzSrrFOS7YKMibEyVdRKDQLyxt8RE+Dnc/cWvkd2t5kq17sfnYKlQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArNS3mxnrCl9ZCCnOs/2JXWZvs/Y+GG6Dywi7P3UNdMABAgIAAQwCAAAAGFwIAAAAAAA=",
"status": "signed"
},
{
"transfer": {
"entries": [
{
"address": "AFzvP594RVzU6WiGyDHwZTmRRSLb8pw2RsHzkksxBP2B",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"value": -552864,
"valueString": "-552864"
},
{
"address": "goS1SabSeeAkSGYDTKAxAtxGDuhVhvdow9hzrAmSs7i",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"value": 547864,
"valueString": "547864"
}
],
"id": "664cb93117afd10ac8b0383829db00ed",
"coin": "tsol",
"wallet": "663bd7b6f7d26f5528c280b7ef3f283c",
"walletType": "hot",
"enterprise": "62c5ae8174ac860007aff138a2d74df7",
"txid": "2M57pzr6p9KUaaEEMHpGTTGU5fzyVbGyKuETkYV7uXvbCv25wecCYhmDk9Rm3D1H47SKpJiqwFN6rr5W6uuhaVwu",
"txidType": "transactionHash",
"txRequestId": "1c4a88bb-7740-44e4-9d08-38c136df7f8e",
"height": 999999999,
"heightId": "999999999-664cb93117afd10ac8b0383829db00ed",
"date": "2024-05-21T15:09:37.235Z",
"type": "send",
"value": -5000,
"valueString": "-5000",
"intendedValueString": "-5000",
"baseValue": 0,
"baseValueString": "0",
"baseValueWithoutFees": 0,
"baseValueWithoutFeesString": "0",
"feeString": "5000",
"payGoFee": 0,
"payGoFeeString": "0",
"usd": -0.00088675,
"usdRate": 177.35,
"state": "signed",
"instant": false,
"isReward": false,
"isUnlock": false,
"isFee": false,
"tags": [
"663bd7b6f7d26f5528c280b7ef3f283c",
"62c5ae8174ac860007aff138a2d74df7"
],
"history": [
{
"date": "2024-05-21T15:09:37.264Z",
"action": "commented",
"comment": "Address balance consolidation"
},
{ "date": "2024-05-21T15:09:37.234Z", "action": "signed" },
{
"date": "2024-05-21T15:09:37.009Z",
"user": "62ab90e06dfda30007974f0a52a12995",
"action": "created"
}
],
"signedDate": "2024-05-21T15:09:37.234Z",
"comment": "Address balance consolidation",
"metadata": [],
"commentedTime": "2024-05-21T15:09:37.264Z",
"signedTime": "2024-05-21T15:09:37.234Z",
"createdTime": "2024-05-21T15:09:37.009Z",
"consolidateId": "664cb910334efb3022281f91c04ab1cd"
},
"txid": "2M57pzr6p9KUaaEEMHpGTTGU5fzyVbGyKuETkYV7uXvbCv25wecCYhmDk9Rm3D1H47SKpJiqwFN6rr5W6uuhaVwu",
"tx": "AUNTUYXexJbz6RjxX1Ga14qwGTPwPd5YpLzBi/4DtY9MBC9Jc43khC5+61KJVP/vXoo6XuYKQWXifyiZfmb15QgBAAEDiZDN7k1FUnqrrJBWaXhRop9j1qK90E28ahsOO6ki79wKMibEyVdRKDQLyxt8RE+Dnc/cWvkd2t5kq17sfnYKlQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA5cmAUpykyqMWtL78+NOLu+WCq+q675rFDp0e/Hf2OAIBAgIAAQwCAAAAGFwIAAAAAAA=",
"status": "signed"
}
],
"failure": []
}Prerequisites
1. (Optional) Check Consolidation Requirements
Determine if your wallet requires consolidations.
Endpoint: Get Wallet by ID
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/wallet/$WALLET_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \Step Result
The response shows either "needsConsolidation": true or "needsConsolidation": false.
{
"allowBackupKeySigning": true,
"approvalsRequired": 1,
"coin": "tbtc4",
...
...
...
"needsConsolidation": true,
"tokenConsolidationState": null,
"tokenAddress": null
}2. Build Consolidation
Begin the manual flow by building a consolidation transaction.
Endpoint: Consolidate Account (Manual)
export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/consolidateAccount/build \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"let params = {
consolidateAddresses: [
'BVMEUTF37WNEQ6GYCZISRFHGLEMOKT5OCPPTTJXVED6JBSXKF6YJJRZRI4',
'7ITFVRNTLUHLD4F2PIIYXXIQOAJAPRGMA7JHSN3SFH2BACLK7WM6CHT524',
],
};
wallet.consolidateAccount(params).then(function (transactions) {
// print generated transactions for signing
console.dir(transaction);
});Step Result
[
{
"txRequestId": "9e4ca1e6-4b61-4a24-97cf-b105f6b9e5c2",
"walletId": "663bd7b6f7d26f5528c280b7",
"txHex": "0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001031419184e91c1a350a33e69cf701115e29ad67b9a9cacb26c9d23e7710145184f0a3226c4c9575128340bcb1b7c444f839dcfdc5af91ddade64ab5eec7e760a950000000000000000000000000000000000000000000000000000000000000000b4fb04953a8154b3cbcd37ec9d7a24897405d5642b41d24f38a4a09a8b99b5da01020200010c02000000b82e0f0000000000",
"feeInfo": { "fee": 5000, "feeString": "5000" },
"txInfo": {
"minerFee": "5000",
"spendAmount": "995000",
"spendAmounts": [{ "coinName": "tsol", "amountString": "995000" }],
"payGoFee": "0",
"outputs": [
{
"address": "goS1SabSeeAkSGYDTKAxAtxGDuhVhvdow9hzrAmSs7i",
"value": 995000,
"wallet": "663bd7b6f7d26f5528c280b7",
"wallets": ["663bd7b6f7d26f5528c280b7"],
"enterprise": "62c5ae8174ac860007aff138",
"enterprises": ["62c5ae8174ac860007aff138"],
"valueString": "995000",
"coinName": "tsol"
}
],
"inputs": [
{
"value": 995000,
"address": "2MTMBrkZ8ufANXEspAygYidLdq23DuchgUbAnVhM5WJ2",
"valueString": "995000"
},
{
"value": 5000,
"address": "2MTMBrkZ8ufANXEspAygYidLdq23DuchgUbAnVhM5WJ2",
"valueString": "5000"
}
],
"type": "Send"
},
"consolidateId": "664cc50265514f8953bbeb8b7a97d284",
"coin": "tsol"
},
{
"txRequestId": "8a14a584-1c18-4f4e-a43f-86b069e6701d",
"walletId": "663bd7b6f7d26f5528c280b7",
"txHex": "01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100010312ea947c2d125bcc5b8d692c8ac770d5dc5fc117f5e21f6f48bcd2aeb14e4bb60a3226c4c9575128340bcb1b7c444f839dcfdc5af91ddade64ab5eec7e760a950000000000000000000000000000000000000000000000000000000000000000b4fb04953a8154b3cbcd37ec9d7a24897405d5642b41d24f38a4a09a8b99b5da01020200010c02000000b82e0f0000000000",
"feeInfo": { "fee": 5000, "feeString": "5000" },
"txInfo": {
"minerFee": "5000",
"spendAmount": "995000",
"spendAmounts": [{ "coinName": "tsol", "amountString": "995000" }],
"payGoFee": "0",
"outputs": [
{
"address": "goS1SabSeeAkSGYDTKAxAtxGDuhVhvdow9hzrAmSs7i",
"value": 995000,
"wallet": "663bd7b6f7d26f5528c280b7",
"wallets": ["663bd7b6f7d26f5528c280b7"],
"enterprise": "62c5ae8174ac860007aff138",
"enterprises": ["62c5ae8174ac860007aff138"],
"valueString": "995000",
"coinName": "tsol"
}
],
"inputs": [
{
"value": 995000,
"address": "2GqoXzwbrMzsihaBFJ7rqv2Wx97TZFoeYXGgtUXfB5rV",
"valueString": "995000"
},
{
"value": 5000,
"address": "2GqoXzwbrMzsihaBFJ7rqv2Wx97TZFoeYXGgtUXfB5rV",
"valueString": "5000"
}
],
"type": "Send"
},
"consolidateId": "664cc50265514f8953bbeb8b7a97d284",
"coin": "tsol"
},
{
"txRequestId": "aa70f489-b8a8-4ad1-828d-7ed5f59a4ce7",
"walletId": "663bd7b6f7d26f5528c280b7",
"txHex": "0100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001038990cdee4d45527aabac9056697851a29f63d6a2bdd04dbc6a1b0e3ba922efdc0a3226c4c9575128340bcb1b7c444f839dcfdc5af91ddade64ab5eec7e760a950000000000000000000000000000000000000000000000000000000000000000b4fb04953a8154b3cbcd37ec9d7a24897405d5642b41d24f38a4a09a8b99b5da01020200010c02000000b82e0f0000000000",
"feeInfo": { "fee": 5000, "feeString": "5000" },
"txInfo": {
"minerFee": "5000",
"spendAmount": "995000",
"spendAmounts": [{ "coinName": "tsol", "amountString": "995000" }],
"payGoFee": "0",
"outputs": [
{
"address": "goS1SabSeeAkSGYDTKAxAtxGDuhVhvdow9hzrAmSs7i",
"value": 995000,
"wallet": "663bd7b6f7d26f5528c280b7",
"wallets": ["663bd7b6f7d26f5528c280b7"],
"enterprise": "62c5ae8174ac860007aff138",
"enterprises": ["62c5ae8174ac860007aff138"],
"valueString": "995000",
"coinName": "tsol"
}
],
"inputs": [
{
"value": 995000,
"address": "AFzvP594RVzU6WiGyDHwZTmRRSLb8pw2RsHzkksxBP2B",
"valueString": "995000"
},
{
"value": 5000,
"address": "AFzvP594RVzU6WiGyDHwZTmRRSLb8pw2RsHzkksxBP2B",
"valueString": "5000"
}
],
"type": "Send"
},
"consolidateId": "664cc50265514f8953bbeb8b7a97d284",
"coin": "tsol"
}
]3. Sign Consolidation
Signing transactions from a MPC wallet is a 3-step process, unless you use external-signing mode, which is only 1 step. See below for details.
3.1 - Send 1st Key Share
Send the first key share to BitGo. You can sign multiple transactions at once by passing the signatureShares parameter with the neccessary key shares for each additional transaction.
Endpoint: Create a Signature Share for the Transaction Request
export WALLET="<WALLET_ID>"
export TX_REQUEST_ID="<TX_REQUEST_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export SHARE="<YOUR_SIGNATURE_SHARE>"
export USER_PUBLIC_GPG_KEY="<YOUR_PUBLIC_GPG_KEY>"
curl -X POST \
https://app.bitgo-test.com/api/v2/wallet/$WALLET_ID/txrequests/$TX_REQUEST_ID/signatureshares \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"signatureShares": [
{
"from": "user",
"to": "bitgo",
"share": "'"$SHARE"'"
}
],
"userPublicGpgKey": "'"$USER_PUBLIC_GPG_KEY"'"
}'Step Result
{
"from": "user",
"to": "user",
"share": "string"
}3.2 - Get 2nd Key Share
Get the 2nd key share from BitGo.
Endpoint: Get Transaction Requests by Wallet
export WALLET="<WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/wallet/$WALLET_ID/txrequests \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"Step Result
{
"txRequests": [
{
"txRequestId": "string",
"version": 0,
"latest": true,
"walletId": "string",
"walletType": "cold",
"enterpriseId": "string",
"state": "initialized",
"date": "2018-05-05T19:46:22.019Z",
"userId": "string",
"intent": {
"nonce": "string",
"memo": "string",
"intentType": "claim",
"sequenceId": "abc123",
"comment": "string",
"stakingRequestId": "string",
"stakingAddress": "string",
"amount": {
"value": "100",
"symbol": "usdc"
}
},
"pendingApprovalId": "string",
"unsignedTxs": [
{
"serializedTxHex": "string",
"signableHex": "string",
"derivationPath": "string",
"feeInfo": {
"feeString": "string",
"fee": 0
}
}
],
"signatureShares": [
{
"from": "user",
"to": "user",
"share": "string"
}
],
"txHashes": [
"string"
]
}
],
"nextBatchPrevId": "string"
}3.3 - Send Complete Key Share
Send the complete key share to BitGo.
Endpoint: Create a Signature Share for the Transaction Request
export WALLET="<WALLET_ID>"
export TX_REQUEST_ID="<TX_REQUEST_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export SHARE="<YOUR_SIGNATURE_SHARE>"
export SIGNATURE_SHARE="<BITGO_OFFSET_SECRET_SHARE>"
export USER_PUBLIC_GPG_KEY="<YOUR_PUBLIC_GPG_KEY>" # Required for ECDSA assets, such as ETH and MATIC
curl -X POST \
https://app.bitgo-test.com/api/v2/wallet/$WALLET_ID/txrequests/$TX_REQUEST_ID/signatureshares \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"signatureShares": [
{
"from": "user",
"to": "bitgo",
"share": "'"$SHARE"'"
}
],
"signerShare": "'"$SIGNATURE_SHARE"'",
"userPublicGpgKey": "'"$USER_PUBLIC_GPG_KEY"'"
}'Step Result
BitGo receives the complete key share and the transaction becomes half-signed, awaiting final signature from BitGo using the BitGo key.
{
"from": "user",
"to": "bitgo",
"share": "string"
}If you prefer to maintain your keys, in the clear, on a separate Express server, you can you can sign transactions for MPC wallets using external-signing mode. BitGo doesn't decrypt your private MPC key shares.
Endpoint: Sign MPC transaction
export COIN="<ASSET_ID>"
export WALLET="<WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export TX_REQUEST_ID="<TX_REQUEST_ID>"
export PRV="<YOUR_PRIVATE_KEY>"
curl -X POST \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/signtxtss \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"txRequestId": "'"$TX_REQUEST_ID"'",
"prv": "'"$PRV"'"
}'Step Result
{
"txRequestId": "string",
"version": 0,
"latest": true,
"walletId": "string",
"walletType": "cold",
"enterpriseId": "string",
"state": "initialized",
"date": {},
"createdDate": {},
"userId": "string",
"intent": {
"intentType": "stake",
"sequenceId": "abc123",
"comment": "string",
"nonce": "string",
"stakingRequestId": "string",
"poolKeyHash": "string"
},
"intents": [
{
"intentType": "stake",
"sequenceId": "abc123",
"comment": "string",
"nonce": "string",
"stakingRequestId": "string",
"poolKeyHash": "string"
}
],
"pendingApprovalId": "string",
"isCanceled": true,
"transactions": [
{
"state": "initialized",
"unsignedTx": {
"serializedTxHex": "string",
"signableHex": "string",
"derivationPath": "string",
"feeInfo": {
"feeString": "string",
"fee": 0
},
"coinSpecific": {},
"parsedTx": {
"minerFee": "string",
"spendAmount": "string",
"spendAmounts": [
{
"coinName": "string",
"amountString": "string"
}
],
"payGoFee": "string",
"outputs": [
{
"address": "string",
"isPayGo": true,
"value": 0,
"wallet": "string",
"walletV1": "string",
"baseAddress": "string",
"enterprise": "string",
"valueString": "string",
"data": "string",
"change": true,
"coinName": "string"
}
],
"inputs": [
{
"derivationIndex": 0,
"value": 0,
"address": "string",
"valueString": "string",
"chain": 0,
"index": 0
}
],
"type": "string",
"memo": "string"
}
},
"signatureShares": [
{
"from": "string",
"to": "string",
"share": "string"
}
],
"commitmentShares": [
{
"from": "string",
"to": "string",
"share": "string",
"type": "commitment"
}
],
"txHash": "string",
"bitgoPaillierChallenge": {
"p": [
"string"
]
}
}
],
"messages": [
{
"coin": "string",
"combineSigShare": "string",
"createdDate": "2019-08-24T14:15:22Z",
"messageEncoded": "string",
"messageRaw": "string",
"signatureShares": [
{
"from": "string",
"to": "string",
"share": "string"
}
],
"state": "initialized",
"txHash": "string",
"updatedDate": "2019-08-24T14:15:22Z"
}
]
}4. Approve Consolidation
Note: You can't approve your own transactions - another admin must approve them.
4.1 Get Pending-Approval ID
To update a pending approval, you must get the pending-approval ID for the pending approval you want to respond to.
Endpoint: List Pending Approvals
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/pendingApprovals \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"Step Result
{
"pendingApprovals": [
{
"id": "59cd72485007a239fb00282ed480da1f",
"coin": "btc",
"wallet": "59cd72485007a239fb00282ed480da1f",
"enterprise": "59cd72485007a239fb00282ed480da1f",
"organization": "59cd72485007a239fb00282ed480da1f",
"creator": "59cd72485007a239fb00282ed480da1f",
"createDate": "2019-08-24T14:15:22Z",
"info": {
"transactionRequest": {
"buildParams": {},
"coinSpecific": {},
"comment": "string",
"fee": "2000000",
"isUnsigned": true,
"recipients": [
{
"address": "2MvrwRYBAuRtPTiZ5MyKg42Ke55W3fZJfZS",
"amount": "2000000",
"data": "string"
}
],
"requestedAmount": "2000000",
"sourceWallet": "59cd72485007a239fb00282ed480da1f",
"triggeredPolicy": "59cd72485007a239fb00282ed480da1f",
"validTransaction": "string",
"validTransactionHash": "string"
},
"type": "transactionRequest"
},
"state": "pending",
"scope": "enterprise",
"userIds": [
"59cd72485007a239fb00282ed480da1f"
],
"approvalsRequired": 1,
"walletLabel": "string",
"resolvers": [
{
"user": "string",
"date": "string",
"resolutionType": "approved",
"signatures": [
"string"
],
"videoApprover": "string",
"videoLink": "string",
"videoException": "string"
}
],
"addressLabels": [
{
"address": "2MvrwRYBAuRtPTiZ5MyKg42Ke55W3fZJfZS",
"label": "Bob's Hot Wallet Address",
"walletLabel": "My Wallet"
}
]
}
]
}4.2 Approve Pending Approval
Endpoint: Update Pending Approval
export APPROVAL_ID="<APPROVAL_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
export OTP="<YOUR_OTP>"
curl -X PUT \
https://app.bitgo-test.com/api/v2/pendingApprovals/$APPROVAL_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"state": "approved",
"otp": "'"$OTP"'"
}'const baseCoin = this.bitgoSDK.coin(initialPendingApproval.coin);
const pendingApproval = await baseCoin.pendingApprovals().get({ id: initialPendingApproval.id });
const result = await pendingApproval.approve(params);Step Result
Once approved, BitGo rebuilds the half-signed transaction, applying the most up-to-date fees.
{
"id": "65529448bd87efe59c3b0156ddfce867",
"coin": "tbtc4",
"wallet": "654ec786c07fe8dc0dcfe03916ec5bb0",
"enterprise": "62c5ae8174ac860007aff138a2d74df7",
"creator": "62ab90e06dfda30007974f0a52a12995",
"createDate": "2023-11-13T21:25:28.022Z",
"info": {
"type": "transactionRequest",
"transactionRequest": {
"requestedAmount": "10000",
"fee": 20451,
"sourceWallet": "654ec786c07fe8dc0dcfe03916ec5bb0",
"policyUniqueId": "654ec786c07fe8dc0dcfe03f",
"recipients": [
{
"address": "2N1UvKhtSHLUa9YomSH7n9YMFCkMG2pbmsQ",
"amount": "10000",
"_id": "65529448bd87efe59c3b0158"
}
],
"coinSpecific": {
"tbtc4": {
"txHex": "010000000001010e4d3af014f9efe311062965d561b67f78a1759e7016605cd506ddd7041762d50000000023220020510ded26d712922bbb61bc68ef6766f836a03527820cbdc8b1551914eb467dafffffffff02102700000000000017a9145a581567fd2a630e61e34a696ab3bb887972886d87ad0f010000000000225120850d0ab466d15cb1565dd528d4d9709f3e46f41d41fe6d94aa01378e626983990500483045022100db45a8d94ee2144f7e29baa855d94a2bf0120707a7ab2fc93734ed94af972c460220558d00b91275aafc7805dfaaf9ab796adbe9f4e66dc467f7eb93b790671a323201000069522103c10ac628c880629ed0fd2a0563a898f4882baca45e15668a4d3064cf1ea379882103e56f84be4460080618ef869bb7b07096880760f748ba23efab533c2359f923bd21020ae81372264b5eac5c9dc7fe0b9a32bad00771c3a2c71f6e2c971823c3182ed653ae00000000"
}
},
"validTransaction": "010000000001010e4d3af014f9efe311062965d561b67f78a1759e7016605cd506ddd7041762d50000000023220020510ded26d712922bbb61bc68ef6766f836a03527820cbdc8b1551914eb467dafffffffff02102700000000000017a9145a581567fd2a630e61e34a696ab3bb887972886d87ad0f010000000000225120850d0ab466d15cb1565dd528d4d9709f3e46f41d41fe6d94aa01378e626983990400483045022100db45a8d94ee2144f7e29baa855d94a2bf0120707a7ab2fc93734ed94af972c460220558d00b91275aafc7805dfaaf9ab796adbe9f4e66dc467f7eb93b790671a323201473044022049e20c0073f42c9636408efc6c833ebf0e1a8ef13e8cb818dde2f4e2af7f7b7f022000cb3a321d65605b9d51d7f87e34306169607646c8d54a44011b021eff3dbe500169522103c10ac628c880629ed0fd2a0563a898f4882baca45e15668a4d3064cf1ea379882103e56f84be4460080618ef869bb7b07096880760f748ba23efab533c2359f923bd21020ae81372264b5eac5c9dc7fe0b9a32bad00771c3a2c71f6e2c971823c3182ed653ae00000000",
"validTransactionHash": "5ea8d2b93997ed9fa3597a2f3113817c8216f573a0278c2533bb5db50fdb0dff"
}
},
"state": "approved",
"scope": "wallet",
"userIds": [
"62ab90e06dfda30007974f0a52a12995",
"621d08a634ad8a0007fcddffd7c429cc"
],
"approvalsRequired": 1,
"singleRunResults": [
{
"ruleId": "Custody Enterprise Transaction ID Verification",
"triggered": false,
"_id": "65529448bd87efe59c3b0157"
}
],
"resolvers": [
{
"user": "621d08a634ad8a0007fcddffd7c429cc",
"date": "2023-11-13T21:44:27.794Z",
"resolutionType": "pending"
}
]
}5. Send Consolidation
Using the txHex returned in the prior step, send the half-signed transaction to BitGo.
Endpoint: Send Half-Signed Transaction
export COIN="<ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X POST \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/tx/send \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"halfSigned": {
"txHex": "010000000001010e4d3af014f9efe311062965d561b67f78a1759e7016605cd506ddd7041762d50000000023220020510ded26d712922bbb61bc68ef6766f836a03527820cbdc8b1551914eb467dafffffffff02102700000000000017a9145a581567fd2a630e61e34a696ab3bb887972886d87ad0f010000000000225120850d0ab466d15cb1565dd528d4d9709f3e46f41d41fe6d94aa01378e626983990500483045022100db45a8d94ee2144f7e29baa855d94a2bf0120707a7ab2fc93734ed94af972c460220558d00b91275aafc7805dfaaf9ab796adbe9f4e66dc467f7eb93b790671a323201000069522103c10ac628c880629ed0fd2a0563a898f4882baca45e15668a4d3064cf1ea379882103e56f84be4460080618ef869bb7b07096880760f748ba23efab533c2359f923bd21020ae81372264b5eac5c9dc7fe0b9a32bad00771c3a2c71f6e2c971823c3182ed653ae00000000"
}
}'let params = {
txHex:
'010000000001010e4d3af014f9efe311062965d561b67f78a1759e7016605cd506ddd7041762d50000000023220020510ded26d712922bbb61bc68ef6766f836a03527820cbdc8b1551914eb467dafffffffff02102700000000000017a9145a581567fd2a630e61e34a696ab3bb887972886d87ad0f010000000000225120850d0ab466d15cb1565dd528d4d9709f3e46f41d41fe6d94aa01378e626983990500483045022100db45a8d94ee2144f7e29baa855d94a2bf0120707a7ab2fc93734ed94af972c460220558d00b91275aafc7805dfaaf9ab796adbe9f4e66dc467f7eb93b790671a323201000069522103c10ac628c880629ed0fd2a0563a898f4882baca45e15668a4d3064cf1ea379882103e56f84be4460080618ef869bb7b07096880760f748ba23efab533c2359f923bd21020ae81372264b5eac5c9dc7fe0b9a32bad00771c3a2c71f6e2c971823c3182ed653ae00000000',
otp: '0000000',
};
wallet.submitTransaction(params).then(function (transaction) {
// print transaction status
console.dir(transaction);
});Step Result
BitGo applies the final signature using the BitGo key and broadcasts the transaction to the blockchain. Your base address receives all available assets from the receive address, maximizing your spendable balance.
{
"transfer": {
"entries": [
{
"address": "2NAVwU9KtPyE4h3RyHkhbLgQQvrc4EuSXD3", // sender address
"wallet": "654ec786c07fe8dc0dcfe03916ec5bb0",
"value": -100000,
"valueString": "-100000"
},
{
"address": "2Mw241n14gJx2PcK2kijidZ2BPGeJBdwp1A", // receiver address
"value": 10000,
"valueString": "10000",
"isChange": false,
"isPayGo": false
},
{
"address": "tb1pq9m0lqjg4lfa0rj9wzjjjumk3l6vecndt8wla5756ktre6h6fexqg7z0vq", // change address that collects the UTXO
"wallet": "654ec786c07fe8dc0dcfe03916ec5bb0",
"value": 70013,
"valueString": "70013",
"isChange": true,
"isPayGo": false
}
],
"id": "65528cde229f765c57a8f4d1eb762908",
"coin": "tbtc4",
"wallet": "654ec786c07fe8dc0dcfe03916ec5bb0",
"walletType": "hot",
"enterprise": "62c5ae8174ac860007aff138a2d74df7",
"txid": "c68916ddc1672ec62c474ef0839ec479ad9b2dabc2249177ce6be6247f81dfe7",
"txidType": "transactionHash",
"height": 999999999,
"heightId": "999999999-65528cde229f765c57a8f4d1eb762908",
"date": "2023-11-13T20:53:51.445Z",
"type": "send",
"value": -29987,
"valueString": "-29987",
"intendedValueString": "-29987",
"baseValue": -10000,
"baseValueString": "-10000",
"baseValueWithoutFees": -10000,
"baseValueWithoutFeesString": "-10000",
"feeString": "19987",
"payGoFee": 0,
"payGoFeeString": "0",
"usd": -11.0275843085,
"usdRate": 36774.55,
"state": "signed",
"instant": false,
"isReward": false,
"isFee": false,
"tags": [
"654ec786c07fe8dc0dcfe03916ec5bb0",
"62c5ae8174ac860007aff138a2d74df7"
],
"history": [
{ "date": "2023-11-13T20:53:51.444Z", "action": "signed" },
{
"date": "2023-11-13T20:53:50.646Z",
"user": "62ab90e06dfda30007974f0a52a12995",
"action": "created"
}
],
"signedDate": "2023-11-13T20:53:51.444Z",
"vSize": 225,
"metadata": [],
"signedTime": "2023-11-13T20:53:51.444Z",
"createdTime": "2023-11-13T20:53:50.646Z"
},
"txid": "c68916ddc1672ec62c474ef0839ec479ad9b2dabc2249177ce6be6247f81dfe7",
"tx": "01000000000101c76ddd01e185e12e995c6f4f36bd440867296d3f224751d73432d465be93478100000000232200204fe0358ee98bef039832fa3a4dc96cb4b265448f3d89c4a05a997a3481f3da6effffffff02102700000000000017a9142962c500562c9db56434702a629ff08fcbd5add0877d110100000000002251200176ff8248afd3d78e4570a52973768ff4cce26d59ddfed3d4d5963ceafa4e4c0400483045022100c4db3db14398d5cc4c9a2a3e4a8fa4fa3b8960ad80eb840e51e182f7561cf6c102207a6410e68aaf7327a1daed83838a39b96e37e22783d879a838640035b6059bcc0147304402205888b2863bb8fc296ed51374db2d03c7fdc746fd0d6c5ceebbe2246bb76b67840220730c8b8395285767ef1049c40cd6cbdecfb5ecfefd795ac2053b28b7a6b0790f0169522103a4c6a0aa167ef75fcf4a96c53b2dd20aee3afa19d1bc2ec4354328ae87c0976621022e4d77a9d0fecafc7ad4f9cfd9144082cf146b27de945ba26d22f26438c5784b2103ee2fef2c21d48bbd0d3813c71269fca6e1bff51e676b1f0131aa29afceb08f8853ae00000000",
"status": "signed"
}Next
You can confirm the increased spendable balance for the wallet in BitGo or using the Get Wallet by Coin and ID endpoint. You can also view the consolidation transaction on a blockchain explorer.
See Also
- API Reference: Consolidate Account (Manual)
- API Reference: Consolidate Account (Simple)
- API Reference: Create a Signature Share for the Transaction Request
- API Reference: Get Transaction Requests by Wallet
- API Reference: Get Wallet by ID
- API Reference: List Pending Approvals
- API Reference: Send Half-Signed Transaction
- API Reference: Sign MPC Transaction
- API Reference: Update Pending Approval
- Concept: Consolidations
Updated 4 months ago