Fees & Gas
This section describes how fees related to transaction execution are calculated and deducted in Tycho.
General Fee Deduction Scheme
In Tycho, there are several types of fees. Fees are deducted at the moment of transaction execution and depend on the execution context and network configuration parameters.
Main types of fees:
account storage fee since the last payment
fee for importing an external incoming message
fee for VM computations, depending on consumed gas
fee for creating outgoing messages
The cost of operations in the masterchain and in workchains may differ.
Network fee information is stored onchain as part of the global configuration.
Storage Fee
storage fee is the fee for account storage.
It is charged every time a transaction is executed on this account.
The fee is calculated based on the time interval since the last payment and is proportional to the size of the stored state. If tariffs have changed over time, the calculation is done per tariff segment and summed.
storage_fee = ceil(((bit_price * bits) + (cell_price * cells)) * delta_seconds / 2^16)Storage cost is regulated by values from ConfigParam 18.
This parameter is stored onchain in the global configuration and contains a Hashmap 32 of type StoragePrices.
Each entry sets storage prices starting from utime_since.
Separate prices are set for the workchain and for the masterchain.
ConfigParam 18 = Hashmap(32, StoragePrices)
StoragePrices:
utime_since: uint32
bit_price_ps: uint64
cell_price_ps: uint64
mc_bit_price_ps: uint64
mc_cell_price_ps: uint64Import Fee
If a transaction is executed based on an external incoming message, the fee for importing this message is deducted from the account balance. This fee depends on the size of the incoming message.
The fee is calculated using the forwarding fee formula.
The calculation considers the bits and cells of the message without the root cell and without the bits in the root cell.
The cost is taken from the onchain config ConfigParam 25.
lump_price is the fixed part of the fee added regardless of the message size.
It covers the base cost of forwarding and, in particular, includes payment for the data in the root cell of the message.
Example data from ConfigParam 25:
Compute fee
compute fee is the fee for executing code in the VM.
It consists of a minimum charge for starting the VM and a charge for the gas actually consumed.
the minimum charge for starting the VM is defined by the
flat_gas_priceparametergas consumed above the
flat_gas_limitthreshold is charged at thegas_pricerate
The fee formula is defined by the GasLimitsPrices parameters in the network configuration.
gas_fee = flat_gas_price + ceil(gas_price * max(0, gas_used - flat_gas_limit) / 2^16)
For the workchain, ConfigParam 21 is used. An example of data from ConfigParam 21.
Action fee
When a transaction is executed, a fee is charged for performing actions in the action phase. This fee is related to creating events and outgoing messages. The fee depends on the size of the generated outgoing messages.
The fee for a single outgoing message is calculated using the forwarding fee formula.
lump_price is the fixed part of the fee that is added regardless of the message size. It covers the base cost of processing an outgoing message and includes payment for the data in the message’s root cell.
The lump_price, bit_price, and cell_price parameters are taken from the on-chain config MsgForwardPrices. For the workchain, ConfigParam 25 is used.
An example of data from ConfigParam 25.
Further Reading
For a deeper technical explanation, refer to the official TON documentation: https://docs.ton.org/foundations/fees
Last updated