💶 Fee Estimation
Understand and implement blockchain fee & gas estimation on Bitcoin-like UTXO chains and EVM chains. Quick start examples, best practices, and FAQs.
Tatum makes it easy to estimate transaction fees across major blockchains:
- UTXO chains (Bitcoin, Litecoin, Bitcoin Cash): fee = feerate per byte × tx size in bytes
- EVM chains (Ethereum and EVM-compatible): fee = gasUsed × (baseFee + priorityFee)
Use this guide to understand how fees work, pick the right Tatum endpoint, and ship with confident defaults.
Jump to chain-specific guides:
Quickly start using Fee Estimation
Option A — Get recommended fee/gas for a chain
Use when you need “fast / standard / slow” suggestions for a network.
curl --request GET \
--url https://api.tatum.io/v3/blockchain/fee/ETH \
--header 'x-api-key: {YOUR_API_KEY}'
Returns network-aware recommendations (e.g., baseFee
, slow
, medium
, fast
).
Option B — Estimate gas for a concrete EVM transaction
Use when you know from
, to
, and amount
(or calldata) and want gasLimit + gasPrice.
curl --request POST \
--url https://api.tatum.io/v4/blockchainOperations/gas \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"chain": "ETH",
"from": "0x0974557990949352a20369fbe6210b3ee64....",
"to": "0xcdfeaf3b4a7beb3cc1fafb7ea34dc9a40b61....",
"amount": "4.5"
}'
Responds with
{ "gasLimit": "24126", "gasPrice": "12000000000" } // gasPrice in wei
Option C — SDK helper (multi-chain)
import { TatumSDK, Network, ApiVersion } from "@tatumio/tatum";
const tatum = await TatumSDK.init({ network: Network.ETHEREUM, version: ApiVersion.V3 });
const fee = await tatum.fee.getCurrentFee(); // slow/medium/fast + baseFee
console.log(fee.data.gasPrice.fast);
API reference:
- Get recommended fee/gas: /reference/getblockchainfee
- Estimate EVM gas for a tx: /reference/estimategas
- Estimate fee for a blockchain tx: /reference/estimatefeeblockchain
Fee models by chain
Blockchain | Unit (what you set) | Model | Practical formula |
---|---|---|---|
Bitcoin (BTC) | sat/vByte | UTXO, market auction | Fee = feerate (sat/vB) × tx size (vB) |
Litecoin (LTC) | litoshi/byte | UTXO | Fee = feerate × tx size |
Bitcoin Cash (BCH) | sat/byte | UTXO | Fee = feerate × tx size |
Ethereum / EVM | gwei per gas (wei on-wire) | Account-based, EIP-1559 | Fee = gasUsed × (baseFee + priorityFee) |
For BTC/LTC/BCH, transaction size depends mainly on inputs and outputs. See:
When to use which Estimation API endpoint?
- I just need the current network fees
→GET https://api.tatum.io/v3/blockchain/fee/{chain}
(slow/medium/fast) - I know the transaction params and want gasLimit + gasPrice (EVM)
→POST https://api.tatum.io/v4/blockchainOperations/gas
- I’m creating/broadcasting with Tatum and want a one-shot estimate
→POST https://api.tatum.io/v3/blockchain/estimate
Tip: For smart contracts (swaps, mints, complex calls), simulate or trace for accurate
gasUsed
. See: EVM simulation & traces
EVM fees in 90 seconds
- Base fee (per block) + priority fee (your tip) = effective gas price.
- You set gasLimit (upper bound). You pay for gasUsed, not for
gasLimit
. - Total fee (ETH) =
gasUsed × (baseFee + priorityFee)
; units on-wire are wei (1 gwei = 10⁹ wei).
Example
- Estimated
gasLimit
=24,126
- Suggested
gasPrice
=12 gwei
- If
gasUsed
=21,000
, fee ≈21,000 × 12 gwei = 252,000 gwei = 0.000252 ETH
.
Too-low priority fee or gasLimit can cause
"gas required exceeds allowance"
or inclusion delays. Preferfast
during congestion.
UTXO fees in 90 seconds (BTC/LTC/BCH)
- Nodes/miners prioritize by feerate (sat/vByte).
- Tx size (vBytes) ≈
(inputs × 148) + (outputs × 34) + 10
(rule of thumb). - Total fee (sats) =
feerate (sat/vB) × size (vB)
.
Example
- Inputs: 2, Outputs: 2 → size ≈ 374 vB
- Feerate: 13.5 sat/vB → fee ≈
374 × 13.5 = 5049 sats
Also know minimum relay fee thresholds. See: UTXO – Minimum relay fee
Best practices
- Refresh often: fees are volatile; compute right before sending.
- Offer choices: expose slow / standard / fast with ETA hints in your UI.
- Guard rails: add max fee caps and sanity checks (e.g., “fee > X% of amount”).
- Simulate contracts: for complex EVM calls, run simulation or use traces.
- Handle stuck txs (UTXO): support RBF/CPFP strategies in wallets.
- Convert units correctly: EVM
gasPrice
is wei; display to users in gwei.
Examples of API Requests
Get recommended BTC fees (slow/standard/fast)
curl --request GET \
--url https://api.tatum.io/v3/blockchain/fee/BTC \
--header 'x-api-key: {YOUR_API_KEY}'
See the BTC guide for manual calculation (sat/vB × vBytes).
Estimate EVM gas for a transfer
curl --request POST \
--url https://api.tatum.io/v4/blockchainOperations/gas \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"chain": "ETH",
"from": "0x....",
"to": "0x....",
"amount": "0.01"
}'
JS SDK – get current network fees
import { TatumSDK, Network, ApiVersion } from "@tatumio/tatum";
const tatum = await TatumSDK.init({ network: Network.BITCOIN, version: ApiVersion.V3 });
const fee = await tatum.fee.getCurrentFee();
console.log(fee.data.gasPrice); // slow/medium/fast/baseFee (+ unit)
Fee Estimation FAQs
What is a blockchain transaction fee?
A transaction fee is the amount you pay to have your transaction processed and included on-chain. On UTXO chains (e.g., Bitcoin) it’s based on bytes of your transaction; on EVM chains (e.g., Ethereum) it’s based on gas used by execution steps.
How do I calculate Bitcoin fees?
Multiply the current feerate (sat/vByte) by your transaction size in vBytes.
Size depends mainly on the number of inputs and outputs.
You can fetch recommended feerates via GET /v3/blockchain/fee/BTC
or see a full example in the
BTC fee guide.
How are Ethereum gas fees calculated?
Ethereum uses EIP-1559: fee = gasUsed × (baseFee + priorityFee).
Use POST /v4/blockchainOperations/gas
to estimate gasLimit and gasPrice for your transaction,
or GET /v3/blockchain/fee/ETH
for network slow/standard/fast suggestions.
How can I reduce gas costs?
Prefer standard over fast during low congestion, batch operations where possible, and consider L2s for smart-contract heavy workflows. Always refresh estimates right before sending.
Why is my transaction stuck or pending?
The fee might be below current network conditions. On Bitcoin-like chains, try rebroadcasting with a higher feerate (RBF/CPFP). On EVM, increase priority fee (tip) or resubmit with a higher gas price.
What is the minimum relay fee?
It’s the lowest feerate nodes accept to relay a transaction. If your BTC/LTC/BCH fee is below that threshold, peers may ignore it. See details in UTXO – Minimum relay fee.
Updated 1 day ago