BTC - Transaction Fee Estimation

Learn how to calculate Bitcoin transaction fees: formula, API calls, and examples with satoshis per byte (sat/vB).

Bitcoin uses a UTXO (Unspent Transaction Output) model, where the transaction fee depends on:

  1. Feerate – how many satoshis per virtual byte (sat/vB) the network currently demands
  2. Transaction size – the size of your transaction in virtual bytes (vB)

This guide shows you how to calculate BTC transaction fees manually and how to fetch them via Tatum’s API.

How to calculate Bitcoin transaction fees

Formula: Fee (satoshis) = feerate (sat/vB) × transaction size (vB)

  • Feerate: dynamic, depends on network congestion.
  • Transaction size: estimated from the number of inputs and outputs in your transaction.

Step 1 — Get the current feerate

Use Tatum’s API to fetch recommended fee rates:

curl --request GET \
  --url https://api.tatum.io/v3/blockchain/fee/BTC \
  --header 'x-api-key: {YOUR_API_KEY}'

Example response:

{
  "fast": 13.5,    // satoshis per vByte
  "medium": 5,
  "slow": 4,
  "block": 813488,
  "time": "2025-09-17T10:14:42.817Z"
}
  • fast → confirm quickly (next block or two)
  • medium → balanced cost vs speed
  • slow → cheapest, may take longer

Alternative: RPC node request

curl --location 'https://bitcoin-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
  "jsonrpc":"1.0",
  "id":"curltext",
  "method":"estimatesmartfee",
  "params":[2]
}'

Example response:

{
  "result": {
    "feerate": 0.00001, // BTC per kilobyte ≈ 10 sat/vB
    "blocks": 2
  },
  "error": null,
  "id": "curltext"
}

Step 2 — Estimate transaction size

A common approximation for non-SegWit transactions:
Size (bytes) = (inputs × 148) + (outputs × 34) + 10

  • Inputs: previous UTXOs being spent
  • Outputs: recipient(s) + change
  • +10 bytes: overhead

📌

For SegWit transactions, the weight/virtual byte system makes real sizes smaller. Rule of thumb: ~68 vB per SegWit input instead of 148.

Step 3 — Calculate total fee

Example with Inputs = 2, Outputs = 2 , Feerate = 13.5 sat/vB

  1. Size = (2 × 148) + (2 × 34) + 10 = 374 bytes ≈ 374 vB
  2. Fee = 374 × 13.5 = 5049 satoshis
  3. Convert: 5049 sats = 0.00005049 BTC

Best practices

  • Refresh frequently – fees change block by block.
  • Offer user choices – expose slow/medium/fast.
  • Guard against stuck txs – support Replace-by-Fee (RBF) and Child-Pays-for-Parent (CPFP).
  • Mind the minimum relay fee – if fee < threshold, nodes may not relay (see: UTXO Minimum Relay Fee)
  • SegWit recommended – lowers transaction size, thus reducing fees.

Example snippets

Get recommended BTC fees

curl --request GET \
  --url https://api.tatum.io/v3/blockchain/fee/BTC \
  --header 'x-api-key: {YOUR_API_KEY}'

JS SDK — fetch current BTC 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 }

Related documentation

Bitcoin Fee Estimation FAQs

How are Bitcoin transaction fees calculated?

Multiply the feerate (sat/vByte) by your transaction size (in vBytes). The size depends on the number of inputs and outputs. Example: 2 inputs, 2 outputs, feerate 13.5 sat/vB → ~5049 sats.

Why are Bitcoin fees sometimes high?

Fees rise during network congestion when many users compete for limited block space. Miners prioritize transactions with higher fees. Spikes often occur during market volatility or NFT/ordinal activity.

How can I reduce my BTC transaction fee?

Use SegWit addresses (lower size), batch outputs, and choose the slow feerate during off-peak hours. For critical transactions, pick fast to avoid delays.

What is the minimum Bitcoin transaction fee?

Bitcoin nodes enforce a minimum relay fee (often 1 sat/vB). Transactions below this may not propagate. See UTXO – Minimum relay fee for details.