Electrum for Bitcoin
Overview
The blockchain.estimatefee
method provides an estimation of the transaction fee per kilobyte needed for a transaction to be included in a block within a specified number of blocks. This is useful for applications that need to dynamically calculate transaction fees based on current network conditions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
number | integer | Yes | The number of blocks within which the transaction should confirm. |
Returns
The method returns the estimated fee in coin units per kilobyte. If the server cannot estimate the fee due to insufficient data, it returns -1.
Field | Description |
---|---|
fee | The estimated transaction fee per kilobyte or -1 if an estimate cannot be made. |
Example Result
0.00101079
Request Example
curl --location 'https://api.tatum.io/v3/blockchain/node/bitcoin-mainnet-electrs/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
"method": "blockchain.estimatefee",
"params": [2],
"id": 1,
"jsonrpc": "2.0"
}'
// yarn add @tatumio/tatum
import { TatumSDK, BitcoinElectrs, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<BitcoinElectrs>({ network: Network.BITCOIN_ELECTRS })
const feeEstimate = await tatum.rpc.estimateFee(2)
console.log('Estimated Fee:', feeEstimate)
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs when done