Block Header

The hash algorithm is multiple iterations of SHA256 that are layered on top of each other via hash commitments. This allows low resource devices to prune various unimportant data.

Usage: Entropy, Blockchaining

The header data structure looks as follows:

SizeNameMeaning
32 byteshashPrevBlockPrevious block hash
4 bytesnBitsCompact encoding of the target for this block
6 bytesnTimeTimestamp of the block (UNIX time), good for 8 million years
2 bytesnReservedReserved for future use, always 0x0000
8 bytesnNonceNonce for miners to tweak the hash
1 bytesnMetaVersionVersion for the data that follows; it should not yet be considered set in stone
7 bytesnSizeBlock size in bytes
4 bytesnHeightBlock height, where the genesis block is 0
32 byteshashEpochBlockHash of the last block which had a height divisible by 5040
32 byteshashMerkleRootMerkle root of the transactions of the block
32 byteshashExtendedMetadataHash of the extended metadata

Layer 1 Header: Chain Layer

This layer allows to very cheaply verify that the blocks form a chain and that PoW has been performed.

Can also be used as a very cheap entropy source if previous block hash is known.

SizeNameMeaning
32 byteshashPrevBlockPrevious block hash
32 byteshashPowLayerSHA256 of Layer 2 Metadata

Layer 2 Header: PoW Layer

This layer allows to verify the PoW and DAA (ASERT only requires time and height).

SPV wallets can store only this layer for blocks that don't contain txs.

A 6 byte timestamp is good for 8 million years; until then we will have reversed SHA256 anyway and have to do a PoW change.

SizeNameMeaning
4 bytesnBitsCompact encoding of the target for this block
6 bytesnTimeTimestamp of the block (UNIX time)
2 bytesnReservedReserved for future use, always 0x0000
8 bytesnNonceNonce for miners to tweak the hash
32 byteshashTxLayerSHA256 of Layer 3 Metadata

Layer 3 Header: Tx layer

This contains the txs merkle root, so we can verify the transactions of the block.

SPV wallets store this layer for blocks that do contain txs they're interested in.

Epochs are 7 days and allow skipping many blocks while still knowing they're connected. This is useful for very low spec devices and smart contracts.

SizeNameMeaning
1 bytesnMetaVersionVersion for the data that follows; it should not yet be considered set in stone
7 bytesnSizeBlock size in bytes
4 bytesnHeightBlock height, where the genesis block is 0
32 byteshashEpochBlockEpoch block hash, 5040 block epochs (7 days)
32 byteshashMerkleRootTxs Merkle root
32 byteshashExtendedMetadataExtended Metadata SHA256d hash

Layer 4: Extended Metadata

This layer is currently unused, and is enforced as the SHA256d of 0 as consensus. However, in the future it is intended to contain additional data that may become relevant for consensus.

Although this could change in the future due to the current enforcement, the currently intended format is:

Optional fields are:

  • 1: extra nonce (1-32 bytes), to tweak the hash some more.
  • 2: memo (1-32 bytes), to leave some arbitrary message
TypeMeaning
var_intnumber of fields
metadata_field[]fields

Metadata field format:

TypeMeaning
4 bytesfield ID
var_intlength
uchar[]data
Edit this page on GitHub Updated at Wed, Apr 3, 2024