<p>Fees in Bitcoin are actually a bit simpler than ethereum, you don't have to deal with gas costs, just a fee per byte.</p>

<p>Bitcoin Core includes an <code>estimatesmartfee</code> function. You can call it (<code>estimatesmartfee 2</code>, for example) and it will give you an idea of the fee rate you need to be confirmed in n blocks (2 in my example).</p>

<p>You can then check your tx size, which varies by number of inputs and outputs, and just multiply it by the fee rate to get your recommended fee, and subtract that from your change output.</p>

CC BY-SA 4.0
2018-07-30T12:00:19.817Z
2018-07-30T12:00:19.817Z
Raghav Sood
<p>Coming from the ethereum development scene, I guess I'm kinda spoiled by the availability of the web3 library which has easy access to the eth.gasPrice and eth.estimateGas methods to get the default gas price and gas limit for raw transactions. I'm wondering if there are similar APIs from the bitcoin clients like Bitcoin Core? So that given a particular transaction, there will be a fast and easy way to calculate a suggested miner fee for it? Thanks.</p>

<transaction-fees><fee-estimation>
Any API to estimate the miner fee for a Bitcoin raw transaction?
hellopeach
# Any API to estimate the miner fee for a Bitcoin raw transaction?

(Asked by: username_0 on 2018-07-30)

Coming from the ethereum development scene, I guess I'm kinda spoiled by the availability of the web3 library which has easy access to the eth.gasPrice and eth.estimateGas methods to get the default gas price and gas limit for raw transactions. I'm wondering if there are similar APIs from the bitcoin clients like Bitcoin Core? So that given a particular transaction, there will be a fast and easy way to calculate a suggested miner fee for it? Thanks.

**Tags:** transaction-fees, fee-estimation


---

## 1 answers

### Answer by username_1 on 2018-07-30. Score: 1 | Accepted answer

Fees in Bitcoin are actually a bit simpler than ethereum, you don't have to deal with gas costs, just a fee per byte.

Bitcoin Core includes an `estimatesmartfee` function. You can call it (`estimatesmartfee 2`, for example) and it will give you an idea of the fee rate you need to be confirmed in n blocks (2 in my example).

You can then check your tx size, which varies by number of inputs and outputs, and just multiply it by the fee rate to get your recommended fee, and subtract that from your change output.


---

