Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
How are TON transaction fees calculated?

How is the gas fee for a transaction on The Open Network calculated?

Votes Newest

Answers


How does the fee count?

First, every TON user should keep in mind that commission depends on many factors. According to the docs, commissions on TON are calculated by this formula:

transactionfee = storagefees + infwdfees + computationfees + actionfees + outfwdfees

storagefees is an amount you pay for storing a smart-contract in the blockchain. In fact, you pay for every second the smart-contract is stored in the blockchain. Your TON wallet is also a smart-contract, which charges the rent every time you receive or send a transaction.

infwdfees is a charge for importing messages from outside the blockchain. Before processing any message, it must be delivered to the validators of the final shardchain. Every time you make a transaction it must be delivered to those validators who will process it. For example, each transaction you make with your wallet app (like Tonkeeper) must first be delivered among validation nodes.

computationfees is an amount you pay for executing code in the virtual machine. The virtual machine receives the input parameters from the sent message and executes the smart-contract code. The more instructions will be executed, the more commission will be. For example, each time you send any transaction with your wallet (which is a smart-contract), you execute the code of your wallet contract.

actionfees is the fee for processing the list of actions received after the smart-contract code execution. With this process, outgoing messages are sent to other smart-contracts or other visible actions made in the blockchain.

outfwdfees – stand for a charge for sending messages outside the TON Blockchain to interact with off-chain services (e.g., logs) and external blockchains. The charge goes to the validators of the final shardchains. Not used since not implemented.

All commissions are nominated and fixed in a certain gas amount, but the gas price itself is not fixed (currently, 1 gas unit costs 1000 nanoTONs). The gas fee, as many other parameters on TON, is configurable* and may be changed by a special vote made in the mainnet. Changing any parameter requires getting two-thirds of the validator votes.

Does it mean that one day gas may become 1000 times higher or even more? Technically, yes, but in fact, no. Validators receive a small fee for processing transactions, and making higher commissions will lead to a decrease in the number of transactions which will make the validating process less beneficial. That’s why there is no point in increasing the fees.

Commissions on TON are difficult to calculate in advance, as their amount depends on transaction run time, account status, message content and size, blockchain's network setting – and also on many variables that cannot be calculated until the transaction is sent. And that is why NFT marketplaces usually take an extra amount of TON just in case and return it later.

It’s important to keep in mind that on TON you pay for both the execution of the smart-contract, and for the used storage (bytes*second). It means you have to pay the rent for having the TON wallet (usually it is very-very small). However, if you have not used your TON wallet for a significant time, you will have to pay a significantly larger commission than usual.

The average number of TON transactions per second, according to tonmon.xyz, is currently 1.4, but fees, unlike on other blockchains, will stay the same if this value increases significantly. According to the official TON website, blockchain is capable of performing millions and, if it becomes necessary, tens of millions of transactions per second, thanks to sharding support.

Today, every transaction costs about ≈0.005 TON. Even if TON’s price increases 50 times, transactions will remain cheaper than on other blockchains. And do not forget that validators may lower this value if they see commissions have become expensive.

Thanks to our subscriber for this question. We were very interested in learning this very comprehensive aspect of TON. We welcome questions and feedback from all our subscribers via our bot. We are always happy to dive deeper and clarify any points about TON.

Fees calculation

storage_fees
storage_fees = ceil((account.bits * bit_price + account.cells * cell_price) * period / 2 ^ 16)

in_fwd_fees, out_fwd_fees
msg_fwd_fees = (lump_price + ceil((bit_price * msg.bits + cell_price * msg.cells)/2^16))

ihr_fwd_fees = ceil((msg_fwd_fees * ihr_price_factor)/2^16)

// bits in the root cell of a message are not included in msg.bits (lump_price pays for them)

action_fees
action_fees = sum(out_ext_msg_fwd_fee) + sum(int_msg_mine_fee)

Config file

All fees are nominated in a certain gas amount and may be changed: The config file represents the current fee's cost.

A direct link to the config file

storage_fees = p18

in_fwd_fees = p24, p25

computation_fees = p20, p21

action_fees = p24, p25

out_fwd_fees = p24, p25

originally appeared on @thedailyton

2
2
Posted 2 years ago
Edited 2 years ago
39K Views
1 Answer
2 years ago
one year ago
Tags