Estimate Fees
Estimate blockchain fees for transactions and check gas tank balances. See the Guide.
-
Estimate the blockchain fee at the time you initiate a transaction. UTXO-based coins return a fee per kB, while account-based coins return a flat fee. BitGo reassesses the actual fee when it receives the final signature, so the sooner your wallet users sign, the more accurate the estimate.
The fee estimate provided by BitGo is higher than the usual network fee. BitGo does not charge this additional fee, but it ensures that transactions process faster and do not fail on the blockchain network.
Prerequisites: Complete Get Started, Create Wallets, and build an unsigned transaction.
-
All tokens on the Ethereum network require a gas tank. If you have an Ethereum-based wallet, you must maintain enough ETH to cover gas fees. BitGo stores this balance in a separate address from the rest of your wallet balance.
// 1. Estimate Fees
export COIN="<ASSET_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/$COIN/tx/fee \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 2. Check Gas Tank Balance
export ENTERPRISE_ID="<YOUR_ENTERPRISE_ID>"
curl -X GET \
https://app.bitgo-test.com/api/v2/$COIN/enterprise/$ENTERPRISE_ID/feeAddressBalance \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 1. Estimate Fees
const BitGoJS = require('../../../src/index.js');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
const Promise = require('bluebird');
// Set your access token here
const accessToken = 'v2xcbe8617bd58947a9ec41cc7a92e0a9a9d81dc2780669faa59eab3016ad5792ae';
// Set your coin of choice here
const coin = 'tbtc4';
Promise.coroutine(function *() {
bitgo.authenticateWithAccessToken({ accessToken });
bitgo.coin(coin).feeEstimate({ numBlocks: 2 }, function callback(err, res) {
console.dir(res);
});
})();
// 2. Check Gas Tank Balance
// Use the REST API for this step (see cURL tab)
// 1. Estimate Fees Response
{
"feePerKb": 15902,
"cpfpFeePerKb": 0,
"numBlocks": 2,
"confidence": 80,
"multiplier": 0,
"feeByBlockTarget": {
"1": 50536,
"2": 15902,
"3": 1579
}
}
// 2. Check Gas Tank Balance Response
{
"balance": "string"
}