Overview
A Starknet block is a list of transactions and a block header that contains multiple fields, including the hash of the previous block and a commitment to their state diff, as well as commitments to the transactions, events, and receipts it includes.Block header fields
| Name | Type | Description |
|---|---|---|
block_number | u64 | The number of this block (i.e., its height) |
parent_block_hash | felt252 | The hash of the block’s parent |
global_state_root | felt252 | A commitment to the new state |
sequencer_address | ContractAddress | The Starknet address of the sequencer that created the block |
block_timestamp | Timestamp | The time at which the sequencer began building the block, in seconds since the Unix epoch |
transaction_count | u32 | The number of transactions in the block |
events_count | u32 | The number of events in the block. |
state_diff_length | u32 | The total amount of storage diffs, nonce updates, deployed contracts, and declared classes |
state_diff_commitment | felt252 | A commitment to the state diff of the block |
transactions_commitment | felt252 | A commitment to the transactions included in the block |
events_commitment | felt252 | A commitment to the events included in the block |
receipts_commitment | felt252 | A commitment to the receipts of the transactions included in the block |
l1_gas_price | (u128, u128) | The price of L1 gas that was used while constructing the block, where the first value is the price in wei and the second is the price in fri (see Fees for more details) |
l1_data_gas_price | (u128, u128) | The price of L1 blob gas that was used while constructing the block, where the first value is the price in wei and the second is the price in fri (see Fees for more details) |
l2_gas_price | (u128, u128) | The price of L2 gas that was used while constructing the block, where the first value is the price in wei and the second is the price in fri (see Fees for more details) |
l1_da_mode | String | CALLDATA or BLOB, depending on how Starknet state diffs are sent to L1 |
protocol_version | String | The version of the Starknet protocol used when creating the block |
Block hash
A block hash is defined by:-
his the Poseidon hash function -
transaction_count || event_count || state_diff_length || l1_da_modeis the concatenation of the 64-bit representations oftransaction_count,event_count, andstate_diff_lengthwith 0 ifl1_da_modeisCALLDATAand 1 ifl1_da_modeisBLOB -
gas_prices_hashis defined by:wherehis the Poseidon hash function andl1_gas_price_wei,l1_gas_price_fri,l1_data_gas_price_wei,l1_data_gas_price_fri,l2_gas_price_wei, andl2_gas_price_friare the wei and fri denominated prices for the three resource types.
For a reference implementation, see
block_hash_calculator.rs in the Starknet sequencer’s GitHub repositoryState diff commitment
The state diff commitment is defined by:-
his the Poseidon hash function -
1and0are placeholders that may be used in the future -
ci,ki,1, vi,1, … , ki,mi,vi,miaremiupdates(ki,1, vi,1), … ,(ki,mi, vi,mi)to contract addressesci
Transactions, events, and receipts commitments
The commitment to transactions, the commitment to events and the commitment to receipts are all roots of height-64 binary Merkle Patricia tries where the leaf at indexi corresponds to:
-
For transactions:
h(transaction_hash, signature)for thei’th transaction included in the block, wherehis the Poseidon hash function. Note that the signature is itself a (possibly empty) array of field elements. -
For events: The event hash of the
i’th emitted event included in the block -
For receipts: The receipt hash of the
i’th transaction receipt included in the block
Event hash
The hash of an event emitted by a contract whose address isemitter_address and a transaction whose hash is tx_hash is defined by:
h is the Poseidon hash function.
Receipt hash
The hash of a transaction receipt is defined by:-
his the Poseidon hash function -
h(messages)formessages = (from1, to1, payload1), … , (fromn, ton, payloadn)is defined by: