When running a transaction such as tezos-client transfer 1 from alice to bob, how does the client computes the transaction fee?


1 Answer 1


The fee computation follows the formula.

The only subtle thing here is that the fee itself can affect the size of the operation in binary. This usually doesn't matter, but to handle the general case, the client currently loops:

  1. Start with the draft op with fee set to zero (with its gas_limit and storage_limit chosen appropriately).
  2. Measure the op size in binary and compute the required fee according to the formula. (If this is the first/only op in a batch, add the fixed overhead for a batch of operations here too.)
  3. If the fee in the op is big enough, we're done. Otherwise, update the fee in the op, and go to #2.

This happens in patch_fee in injection.ml.

  • I am not sure it uses this code. Instead, I think it calls the node through RPCs, this is explained in the blog post cited by my reply.
    – lefessan
    Feb 14, 2019 at 21:18
  • RPCs are indeed used to estimate gas and storage usage, and more, but there is no RPC for calculating the minimum fee. The code I linked is used.
    – Tom
    Feb 14, 2019 at 22:19
  • 1
    (To see this happening, try tezos-client -l without specifying a fee, as in the blog post. You will notice that the run_operation is called with 0 fee, and then preapply is mysteriously called with the correct minimal fee, not returned yet by any RPC, but calculated by the client after run_operation.)
    – Tom
    Feb 14, 2019 at 22:37
  • Oh yes, I thought it was about gas and burn. I will delete my answer.
    – lefessan
    Feb 14, 2019 at 23:43

Your Answer

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

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