Overview

You can estimate the blockchain fee at the time you initiate a transaction. However, BitGo assesses the actual fee upon receiving the final signature that approves the transaction. Therefore, the sooner your wallet users sign the transaction, the more accurate the fee estimation is.

UTXO-based coins return a fee per kB. Account-based coins return a flat fee.

feeByBlockTarget is a JSON object whose property names are block-count targets (for example, "1" means the next block, "6" means within 6 blocks). These are not cryptographic keys.

Note

The fee estimate provided by BitGo is higher than the usual network fee. This additional fee is not charged by BitGo but is used to ensure that the transactions process faster and don't fail on the blockchain network.

Prerequisites

Cookbook

Need just the steps? Expand the cookbook below to get started:

Estimate FeesOpen Cookbook

Steps

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 = process.env.ASSET_ID;

Promise.coroutine(function *() {
  bitgo.authenticateWithAccessToken({ accessToken });
  bitgo.coin(coin).feeEstimate({ numBlocks: 2 }, function callback(err, res) {
     console.dir(res);
  });
})();

Step Result

{
  "feePerKb": 1000,
  "cpfpFeePerKb": 1000,
  "numBlocks": 2,
  "feeByBlockTarget": {
    "1": 1000,
    "2": 1000,
    "3": 1000,
    "4": 1000,
    "5": 1000,
    "6": 1000,
    "10": 1000,
    "20": 1000,
    "50": 1000,
    "100": 1000,
    "144": 1000
  }
}

Checking Gas Tank Balance

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 holds this balance in a separate address from the rest of your wallet balance.

Steps


GET /api/v2/{coin}/enterprise/{enterpriseId}/feeAddressBalance

{
  "duration": 0
}

Step Result

{
  "balance": "0",
  "address": "0x3a8c19d7e04b52f9a1c6e83d71f2b0a5c94e7d8"
}

Next

Sign the transaction.

See Also