Skip to main content

Block layout

info

To maximize comprehension of this page, it is highly recommended that you familiarize yourself with the TL-B language.

A block in the blockchain is a record of new transactions that, once confirmed, is added to the blockchain as a permanent and immutable part of the decentralized ledger. Each block includes transaction data, timestamps, and a reference to the previous block, forming a block chain.

Blocks in TON Blockchain have a relatively complex structure, reflecting the system’s overall design. This page outlines the structure and layout of these blocks.

Block

The raw TL-B scheme of a block is as follows:

block#11ef55aa global_id:int32
info:^BlockInfo value_flow:^ValueFlow
state_update:^(MERKLE_UPDATE ShardState)
extra:^BlockExtra = Block;

Let’s take a closer look at each field.

global_id:int32

The identifier of the network where this block was created. For example, -239 represents the Mainnet, and -3 represents the Testnet.

info:^BlockInfo

This field contains metadata about the block, including its version, sequence numbers, identifiers, and various flags.

block_info#9bc7a987 version:uint32
not_master:(## 1)
after_merge:(## 1) before_split:(## 1)
after_split:(## 1)
want_split:Bool want_merge:Bool
key_block:Bool vert_seqno_incr:(## 1)
flags:(## 8) { flags <= 1 }
seq_no:# vert_seq_no:# { vert_seq_no >= vert_seqno_incr }
{ prev_seq_no:# } { ~prev_seq_no + 1 = seq_no }
shard:ShardIdent gen_utime:uint32
start_lt:uint64 end_lt:uint64
gen_validator_list_hash_short:uint32
gen_catchain_seqno:uint32
min_ref_mc_seqno:uint32
prev_key_block_seqno:uint32
gen_software:flags . 0?GlobalVersion
master_ref:not_master?^BlkMasterInfo
prev_ref:^(BlkPrevInfo after_merge)
prev_vert_ref:vert_seqno_incr?^(BlkPrevInfo 0)
= BlockInfo;
FieldTypeDescription
versionuint32Specifies the version of the block structure.
not_master(## 1)Indicates whether the block is a non-MasterChain block.
after_merge(## 1)Indicates whether the block was created immediately after merging two ShardChains, i.e., it has two parent blocks.
before_split(## 1)Indicates whether the block was created immediately before a ShardChain split.
after_split(## 1)Indicates whether the block was created immediately after a ShardChain split.
want_splitBoolSpecifies whether a ShardChain split is desired.
want_mergeBoolSpecifies whether a ShardChain merge is desired.
key_blockBoolIndicates whether the block is a key block.
vert_seqno_incr(## 1)Specifies the increment of the vertical sequence number.
flags(## 8)Contains additional flags related to the block.
seq_no#The sequence number is assigned to the block.
vert_seq_no#The vertical sequence number of the block.
shardShardIdentIdentifies the shard to which the block belongs.
gen_utimeuint32The block generation time.
start_ltuint64Logical time at the start of the block’s lifespan.
end_ltuint64Logical time at the end of the block’s lifespan.
gen_validator_list_hash_shortuint32A short hash of the validator list is active during block generation.
gen_catchain_seqnouint32The CatChainsequence number is associated with the block.
min_ref_mc_seqnouint32The minimum sequence number of the referenced MasterChain block.
prev_key_block_seqnouint32The sequence number of the previous key block.
gen_softwareGlobalVersionSpecifies the software version that generated the block. Present only if the first bit of the version is set to 1.
master_refBlkMasterInfoA reference to the MasterChain block if the current block is not a MasterChain block.
prev_refBlkPrevInfo after_mergeA reference to the previous block in the chain.
prev_vert_refBlkPrevInfo 0A reference to the last block in the vertical sequence, if applicable.

value_flow:^ValueFlow

Represents the currency flow within the block, including collected fees and other currency-related transactions.

value_flow#b8e48dfb ^[ from_prev_blk:CurrencyCollection
to_next_blk:CurrencyCollection
imported:CurrencyCollection
exported:CurrencyCollection ]
fees_collected:CurrencyCollection
^[
fees_imported:CurrencyCollection
recovered:CurrencyCollection
created:CurrencyCollection
minted:CurrencyCollection
] = ValueFlow;
FieldTypeDescription
from_prev_blkCurrencyCollectionIndicates the currency flow from the previous block.
to_next_blkCurrencyCollectionIndicates the currency flow to the next block.
importedCurrencyCollectionSpecifies the amount of currency imported into the block.
exportedCurrencyCollectionSpecifies the amount of currency exported from the block.
fees_collectedCurrencyCollectionThe total amount of fees collected within the block.
fees_importedCurrencyCollectionThe fees imported into the block. Non-zero only in MasterChain.
recoveredCurrencyCollectionThe currency recovered in the block Non-zero only in MasterChain.
createdCurrencyCollectionAmount of new currency created in the block. Non-zero only in MasterChain.
mintedCurrencyCollectionThe currency minted in the block. Non-zero only in MasterChain.

state_update:^(MERKLE_UPDATE ShardState)

Indicates the updated state of the shard after this block.

!merkle_update#02 {X:Type} old_hash:bits256 new_hash:bits256
old:^X new:^X = MERKLE_UPDATE X;
FieldTypeDescription
old_hashbits256The hash of the previous shard state.
new_hashbits256The hash of the updated shard state.
oldShardStateThe previous shard state was stored as a reference.
newShardStateThe updated shard state is stored as a reference.

ShardState

ShardState can contain either information about a single shard or, if the shard has been split, information about its left and right parts.

_ ShardStateUnsplit = ShardState;
split_state#5f327da5 left:^ShardStateUnsplit right:^ShardStateUnsplit = ShardState;

ShardState unsplitted

shard_state#9023afe2 global_id:int32
shard_id:ShardIdent
seq_no:uint32 vert_seq_no:#
gen_utime:uint32 gen_lt:uint64
min_ref_mc_seqno:uint32
out_msg_queue_info:^OutMsgQueueInfo
before_split:(## 1)
accounts:^ShardAccounts
^[ overload_history:uint64 underload_history:uint64
total_balance:CurrencyCollection
total_validator_fees:CurrencyCollection
libraries:(HashmapE 256 LibDescr)
master_ref:(Maybe BlkMasterInfo) ]
custom:(Maybe ^McStateExtra)
= ShardStateUnsplit;
FieldTypeRequiredDescription
global_idint32YesAn ID of the network where this shard resides. -239 for Mainnet, -3 for Testnet.
shard_idShardIdentYesThe unique identifier of the shard.
seq_nouint32YesThe latest sequence number of this ShardChain.
vert_seq_no#YesThe latest vertical sequence number of this ShardChain.
gen_utimeuint32YesThe generation time associated with the creation of the shard.
gen_ltuint64YesThe logical time at which the shard was generated.
min_ref_mc_seqnouint32YesThe sequence number of the latest referenced MasterChain block.
out_msg_queue_infoOutMsgQueueInfoYesMetadata about the shard’s outbound message queue. Stored in a reference.
before_split## 1YesA flag indicating that the next block of this ShardChain. It initiates a split.
accountsShardAccountsYesA reference to the current state of accounts within the shard.
overload_historyuint64YesA counter tracking shard overload events. Used to inform sharding decisions.
underload_historyuint64YesA counter tracking shard underload events. Used to inform sharding decisions.
total_balanceCurrencyCollectionYesThe total balance is held across all accounts in the shard.
total_validator_feesCurrencyCollectionYesThe total amount of validator fees accumulated within the shard.
librariesHashmapE 256 LibDescrYesA hashmap of libraries used in the shard. This is usually empty, except in the MasterChain.
master_refBlkMasterInfoNoA reference to the masterchain block info.
customMcStateExtraNoMasterChain-specific extra data. Present only in the MasterChain. Stored in a reference.

ShardState splitted

FieldTypeDescription
leftShardStateUnsplitThe state of the left shard after the split. Stored in a reference.
rightShardStateUnsplitThe state of the right shard after the split. Stored in a reference.

extra:^BlockExtra

This field contains extra information about the block.

block_extra in_msg_descr:^InMsgDescr
out_msg_descr:^OutMsgDescr
account_blocks:^ShardAccountBlocks
rand_seed:bits256
created_by:bits256
custom:(Maybe ^McBlockExtra) = BlockExtra;
FieldTypeRequiredDescription
in_msg_descrInMsgDescrYesThe descriptor for the incoming messages in the block. Stored in a reference.
out_msg_descrOutMsgDescrYesThe descriptor for the outgoing messages in the block. Stored in a reference.
account_blocksShardAccountBlocksYesThe collection of all transactions processed in the block, along with updates to the states of accounts assigned to the shard and stored in a reference.
rand_seedbits256YesThe random seed for the block.
created_bybits256YesThe entity, usually a validator's public key, that created the block.
customMcBlockExtraNoIt contains masterchain-specific data, such as custom extra data for the block. Present only in the MasterChain. Stored in a reference.

McBlockExtra

This field contains extra information about the MasterChain block.

masterchain_block_extra#cca5
key_block:(## 1)
shard_hashes:ShardHashes
shard_fees:ShardFees
^[ prev_blk_signatures:(HashmapE 16 CryptoSignaturePair)
recover_create_msg:(Maybe ^InMsg)
mint_msg:(Maybe ^InMsg) ]
config:key_block?ConfigParams
= McBlockExtra;
FieldTypeRequiredDescription
key_block## 1YesFlag indicating whether the block is a key block.
shard_hashesShardHashesYesThe hashes of the latest blocks for the corresponding ShardChains.
shard_feesShardFeesYesThe total fees are collected from all shards in this block.
prev_blk_signaturesHashmapE 16 CryptoSignaturePairYesSignatures of the previous block.
recover_create_msgInMsgNoThe message related to recovering extra-currencies, if any. Stored in a reference.
mint_msgInMsgNoThe message related to minting extra-currencies, if any. Stored in a reference.
configConfigParamsNoThe actual configuration parameters for this block. Present only if key_block is set.

See also

  • The initial explanation of the block layout from the whitepaper.