0

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.

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.