Transaction layout
It's highly recommended that you familiarize yourself with the TL-B language to better understand this page.
The TON blockchain functions through three main components: accounts, messages, and transactions. This section outlines the structure and organization of transactions.
A transaction is an action that handles incoming and outgoing messages for a particular account, modifying its state and potentially generating fees for validators.
Transaction
transaction$0111 account_addr:bits256 lt:uint64
prev_trans_hash:bits256 prev_trans_lt:uint64 now:uint32
outmsg_cnt:uint15
orig_status:AccountStatus end_status:AccountStatus
^[ in_msg:(Maybe ^(Message Any)) out_msgs:(HashmapE 15 ^(Message Any)) ]
total_fees:CurrencyCollection state_update:^(HASH_UPDATE Account)
description:^TransactionDescr = Transaction;
Field | Type | Required | Description |
---|---|---|---|
account_addr | bits256 | Yes | The hash of the address where the transaction was executed. Learn more about addresses |
lt | uint64 | Yes | Represents Logical time. Learn more about logical time |
prev_trans_hash | bits256 | Yes | The hash of the previous transaction for this account. |
prev_trans_lt | uint64 | Yes | The lt of the previous transaction for this account. |
now | uint32 | Yes | The now value set during the transaction execution. It is a UNIX timestamp in seconds. |
outmsg_cnt | uint15 | Yes | The count of outgoing messages generated during the transaction execution. |
orig_status | AccountStatus | Yes | The status of this account before the transaction was executed. |
end_status | AccountStatus | Yes | The status of the account after the transaction was executed. |
in_msg | (Message Any) | No | The incoming message that triggered the transaction execution. Stored as a reference. |
out_msgs | HashmapE 15 ^(Message Any) | Yes | A dictionary containing the outgoing messages created during the transaction execution. |
total_fees | CurrencyCollection | Yes | The total fees collected during the transaction execution, including TON coin and potentially some extra-currencies. |
state_update | HASH_UPDATE Account | Yes | The HASH_UPDATE structure represents the state change. Stored as a reference. |
description | TransactionDescr | Yes | A detailed description of the transaction execution process. Stored as a reference. |
AccountStatus
acc_state_uninit$00 = AccountStatus;
acc_state_frozen$01 = AccountStatus;
acc_state_active$10 = AccountStatus;
acc_state_nonexist$11 = AccountStatus;
[00]
: Account is uninitialized.[01]
: Account is frozenю[10]
: Account is activeю[11]
: Account does not existю
HASH_UPDATE
update_hashes#72 {X:Type} old_hash:bits256 new_hash:bits256
= HASH_UPDATE X;
Field | Type | Description |
---|---|---|
old_hash | bits256 | The hash represents the account state before transaction execution. |
new_hash | bits256 | The hash represents the account state following transaction execution. |
TransactionDescr types
Ordinary
This is the most common transaction type, meeting most developers' requirements. Transactions of this type have a single incoming message and can generate multiple outgoing messages.
trans_ord$0000 credit_first:Bool
storage_ph:(Maybe TrStoragePhase)
credit_ph:(Maybe TrCreditPhase)
compute_ph:TrComputePhase action:(Maybe ^TrActionPhase)
aborted:Bool bounce:(Maybe TrBouncePhase)
destroyed:Bool
= TransactionDescr;
Field | Type | Required | Description |
---|---|---|---|
credit_first | Bool | Yes | A flag related to the bounce flag of an incoming message. credit_first = !bounce . |
storage_ph | TrStoragePhase | No | Contains information about the storage phase during the transaction execution. More info |
credit_ph | TrCreditPhase | No | Contains information about the credit phase during the transaction execution. More info |
compute_ph | TrComputePhase | Yes | Contains information about the compute phase during the transaction execution. More info |
action | TrActionPhase | No | Contains information about the action phase during the transaction execution. More info. Stored in a reference. |
aborted | Bool | Yes | Indicates whether the transaction execution was aborted. |
bounce | TrBouncePhase | No | Contains information about the bounce phase during the transaction execution. More info |
destroyed | Bool | Yes | Indicates whether the account was destroyed during the execution. |
Storage
Validators can add transactions of this type as they see fit. They do not handle incoming messages or trigger codes. Their sole purpose is to collect storage fees from an account, impacting its storage statistics and balance. If the resulting TON coin balance of the account falls below a specified threshold, the account may be frozen, and its code and data will be replaced with their combined hash.
trans_storage$0001 storage_ph:TrStoragePhase
= TransactionDescr;
Field | Type | Description |
---|---|---|
storage_ph | TrStoragePhase | Contains information about the storage phase of a transaction execution. More Info |
Tick-tock
Tick
and Tock
transactions are designated for special system smart contracts that must be automatically invoked in every block. Tick
transactions are executed at the start of each MasterChain block, while Tock
transactions are initiated at the end.
trans_tick_tock$001 is_tock:Bool storage_ph:TrStoragePhase
compute_ph:TrComputePhase action:(Maybe ^TrActionPhase)
aborted:Bool destroyed:Bool = TransactionDescr;
Field | Type | Required | Description |
---|---|---|---|
is_tock | Bool | Yes | A flag that indicates the type of transaction used to distinguish between Tick and Tock transactions. |
storage_ph | TrStoragePhase | Yes | Provides information about the storage phase of the transaction execution. More info |
compute_ph | TrComputePhase | Yes | Provides information about the compute phase of the transaction execution. More info |
action | TrActionPhase | No | Provides information about the action phase of the transaction execution. More info. Stored as a reference. |
aborted | Bool | Yes | Indicates whether the transaction execution was aborted. |
destroyed | Bool | Yes | Indicates whether the account was destroyed during execution. |
Split prepare
This type of transaction is currently not in use, and details about its implementation are limited.
Split transactions are designed for large smart contracts that must be divided due to high load. The contract must support this transaction type and manage the splitting process to distribute the load effectively.
Split prepare transactions are triggered when a smart contract needs to be split. The smart contract should generate the state necessary to create a new instance that will be deployed.
trans_split_prepare$0100 split_info:SplitMergeInfo
storage_ph:(Maybe TrStoragePhase)
compute_ph:TrComputePhase action:(Maybe ^TrActionPhase)
aborted:Bool destroyed:Bool
= TransactionDescr;
Field | Type | Required | Description |
---|---|---|---|
split_info | SplitMergeInfo | Yes | Contains information about the split process. |
storage_ph | TrStoragePhase | No | Provides details about the storage phase during transaction execution. More info |
compute_ph | TrComputePhase | Yes | CContains details about the compute phase during transaction execution. More info |
action | TrActionPhase | No | Provides information about the action phase during transaction execution. More info. Stored as a reference. |
aborted | Bool | Yes | Indicates whether the transaction execution was aborted. |
destroyed | Bool | Yes | Indicates whether the account was destroyed during execution. |
Split install
This transaction type is currently unavailable, and available information is limited.
Split install transactions are used to deploy new instances of large smart contracts. A split prepare transaction generates the state for the new contract.
trans_split_install$0101 split_info:SplitMergeInfo
prepare_transaction:^Transaction
installed:Bool = TransactionDescr;
Field | Type | Description |
---|---|---|
split_info | SplitMergeInfo | Information about the split process. |
prepare_transaction | Transaction | Information about the transaction prepared for the split operation. Stored as a reference. |
installed | Bool | Indicates whether the transaction was installed. |
Merge prepare
This transaction type is currently unavailable, and available information is limited.
Merge transactions are triggered for large smart contracts that need to recombine after being split under high load. The contract must support this transaction type and handle the merging process to help balance system resources.
Merge prepare transactions are initiated when two smart contracts are set to merge. The contract should generate a message to the other instance to initiate and facilitate the merge process.
trans_merge_prepare$0110 split_info:SplitMergeInfo
storage_ph:TrStoragePhase aborted:Bool
= TransactionDescr;
Field | Type | Description |
---|---|---|
split_info | SplitMergeInfo | Information about the merge process. |
storage_ph | TrStoragePhase | Contains information about the storage phase during transaction execution. More info |
aborted | Bool | Indicates whether the transaction execution was aborted. |
Merge install
This transaction type is currently unavailable, and available information is limited.
Merge install transactions are used to merge instances of large smart contracts. A merge prepare transaction generates a special message that facilitates the merge.
trans_merge_install$0111 split_info:SplitMergeInfo
prepare_transaction:^Transaction
storage_ph:(Maybe TrStoragePhase)
credit_ph:(Maybe TrCreditPhase)
compute_ph:TrComputePhase action:(Maybe ^TrActionPhase)
aborted:Bool destroyed:Bool
= TransactionDescr;
Field | Type | Required | Description |
---|---|---|---|
split_info | SplitMergeInfo | Yes | Information about the merge process. |
prepare_transaction | Transaction | Yes | Information about the transaction prepared for the merge operation. Stored as a reference. |
storage_ph | TrStoragePhase | No | Contains information about the storage phase of transaction execution. More info |
credit_ph | TrCreditPhase | No | Contains information about the credit phase of transaction execution. More info |
compute_ph | TrComputePhase | Yes | Contains information about the compute phase of transaction execution. More info |
action | TrActionPhase | No | Contains information about the action phase of transaction execution. More info. Stored as a reference. |
aborted | Bool | Yes | Indicates whether the transaction was aborted during execution. |
destroyed | Bool | Yes | Indicates whether the account was destroyed during execution. |
See also
- The initial explanation of the transaction layout from the whitepaper.