When running a transaction such as
tezos-client transfer 1 from alice to bob, how does the client computes the transaction fee?
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:
- Start with the draft op with fee set to zero (with its gas_limit and storage_limit chosen appropriately).
- 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.)
- 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.