Low-level fees overview
This section describes instructions and manuals for interacting with TON at a low level.
Here you will find the raw formulas for calculating commissions and fees on TON.
However, most of them are already implemented through opcodes! So, you use them instead of manual calculations.
This document provides a general idea of transaction fees on TON and particularly computation fees for the FunC code. There is also a detailed specification in the TVM whitepaper.
Transactions and phases
As was described in the TVM overview, transaction execution consists of a few phases. During those phases, the corresponding fees may be deducted. There is a high-level fees overview.
Storage fee
TON validators collect storage fees from smart contracts.
Storage fees are collected from the smart contract balance at the Storage phase of any transaction due storage payments for the account state (including smart-contract code and data, if present) up to the present time. The smart contract may be frozen as a result.
It’s important to keep in mind that on TON you pay for both the execution of a smart contract and for the used storage (check @thedailyton article). storage fee
depends on you contract size: number of cells and sum of number of bits from that cells. Only unique hash cells are counted for storage and fwd fees i.e. 3 identical hash cells are counted as one. It means you have to pay a storage fee for having TON Wallet (even if it's very-very small).
If you have not used your TON Wallet for a significant period of time (1 year), you will have to pay a significantly larger commission than usual because the wallet pays commission on sending and receiving transactions.
Note: When message is bounced from the contract, the contract will pay current debt for storage aka storage_fee
Formula
You can approximately calculate storage fees for smart contracts using this formula:
storage_fee = (cells_count * cell_price + bits_count * bit_price)
* time_delta / 2^16
Let's examine each value more closely:
storage_fee
—price for storage fortime_delta
secondscells_count
—count of cells used by smart contractbits_count
—count of bits used by smart contractcell_price
—price of single cellbit_price
—price of single bit
Both cell_price
and bit_price
could be obtained from Network Config param 18.
Current values are:
- Workchain.
bit_price_ps:1
cell_price_ps:500 - Masterchain.
mc_bit_price_ps:1000
mc_cell_price_ps:500000