How to get block's tx fees from RPC?

Hi, I can’t seem to find a method that would return information about tx fees (per tx or summarized, any form is ok) in a mined block, could anyone point me in the right direction?

1 Like

Thanks, so from what I understand this is not implemented, same for the default fee. So how do the blockchain explorers get the tx fees?

You can get all the information at the transaction level. Note you’d need to set -txindex=1 when launching zcashd or adding this to zcash.conf.

Find the latest block:
zcash-cli getbestblockhash

Get the info about the block
zcash-cli getblock 00000000000681529cd55765207b1130b575500cf4fba0e7456195b41785ea21

This includes an array of transactions, so from that get the raw transaction:

zcash-cli getrawtransaction 868c510a5c3df4672b8911c010c2555041b454854b0ebd23e52615f82752fbce

Then finally get the details of the transaction:
zcash-cli decoderawtransaction <output of previous command>

You can then calculate the fees as sum of all outputs minus sum of all inputs as fees are always transparent.

1 Like

Ah, I was missing the -txindex=1 flag, I’ve used decoderawtransaction but only got zatoshi for vouts. Thanks.

1 Like