There are three ways:
-
There are a default option
min_fee_rate
in theckb.toml
: 1000 Shannons/KB. For a typical transfer tx which contains two inputs and two outputs, the tx size is597
bytes, to calculate tx fee we need plus extra4
bytes for the serialization consumption; so the min tx fee is(597 + 4) * 1000 / 1000 = 601 shannons
. You can send a tx with601 shannons
fee, and try to increase the fee if the tx can’t get committed. https://github.com/nervosnetwork/ckb/blob/develop/resource/ckb.toml#L109 -
CKB has an RPC to estimate tx fee by statistic the average committed time of txs, but since the current mainnet has very few transactions been committed, so it may not accuracy https://docs.nervos.org/api/rpc.html#estimate_fee_rate
-
For some special txs that consume massive cycles, we can’t just estimate it by the tx size, you need to pay more fees to get committed fast.
If you want to write a wallet or such tools, the advice is to combine these strategies to find a proper fee.
Just remember we have a wiki document for transaction fee https://github.com/nervosnetwork/ckb/wiki/Transaction-»-Transaction-Fee