P2P message format

Block header (shell)

Name Size Contents
level 4 bytes signed 32-bit integer
proto 1 byte unsigned 8-bit integer
predecessor 32 bytes bytes
timestamp 8 bytes signed 64-bit integer
validation_pass 1 byte unsigned 8-bit integer
operations_hash 32 bytes bytes
# bytes in field “fitness” 4 bytes unsigned 30-bit integer
fitness Variable sequence of $fitness.elem
context 32 bytes bytes
protocol_data Variable bytes

fitness.elem

Name Size Contents
# bytes in next field 4 bytes unsigned 30-bit integer
Unnamed field 0 Variable bytes

Operation (shell)

Name Size Contents
branch 32 bytes bytes
data Variable bytes

Block_header (alpha-specific)

Name Size Contents
priority 2 bytes unsigned 16-bit integer
proof_of_work_nonce 8 bytes bytes
? presence of field “seed_nonce_hash” 1 byte boolean (0 for false, 255 for true)
seed_nonce_hash 32 bytes bytes
signature 64 bytes bytes

Operation (alpha-specific)

Name Size Contents
contents Variable sequence of $operation.alpha.contents
signature 64 bytes bytes

X_0

Name Size Contents
entrypoint Determined from data $entrypoint
? presence of field “value” 1 byte boolean (0 for false, 255 for true)
value Determined from data $fitness.elem

X_2

Name Size Contents
fee_gas Determined from data $N.t
? presence of field “reveal_public_key” 1 byte boolean (0 for false, 255 for true)
reveal_public_key Determined from data $public_key

X_3

Name Size Contents
target 21 bytes $public_key_hash
? presence of field “signature” 1 byte boolean (0 for false, 255 for true)
signature 64 bytes bytes

X_5

Name Size Contents
# bytes in next field 4 bytes unsigned 30-bit integer
Unnamed field 0 Variable sequence of signed 64-bit integer

Z.t

A variable length sequence of bytes, encoding a Zarith number. Each byte has a running unary size bit: the most significant bit of each byte tells is this is the last byte in the sequence (0) or if there is more to read (1). The second most significant bit of the first byte is reserved for the sign (positive if zero). Size and sign bits ignored, data is then the binary representation of the absolute value of the number in little endian order.

Name Size Contents
Z.t Determined from data bytes

X_6

Name Size Contents
# bytes in next field 4 bytes unsigned 30-bit integer
Unnamed field 0 Variable bytes

X_4

Name Size Contents
? presence of field “proof_of_work_nonce_size” 1 byte boolean (0 for false, 255 for true)
proof_of_work_nonce_size 1 byte unsigned 8-bit integer
? presence of field “nonce_length” 1 byte boolean (0 for false, 255 for true)
nonce_length 1 byte unsigned 8-bit integer
? presence of field “max_revelations_per_block” 1 byte boolean (0 for false, 255 for true)
max_revelations_per_block 1 byte unsigned 8-bit integer
? presence of field “max_operation_data_length” 1 byte boolean (0 for false, 255 for true)
max_operation_data_length 4 bytes signed 31-bit integer in the range -1073741824 to 1073741823
? presence of field “max_proposals_per_delegate” 1 byte boolean (0 for false, 255 for true)
max_proposals_per_delegate 1 byte unsigned 8-bit integer
? presence of field “preserved_cycles” 1 byte boolean (0 for false, 255 for true)
preserved_cycles 1 byte unsigned 8-bit integer
? presence of field “blocks_per_cycle” 1 byte boolean (0 for false, 255 for true)
blocks_per_cycle 4 bytes signed 32-bit integer
? presence of field “blocks_per_commitment” 1 byte boolean (0 for false, 255 for true)
blocks_per_commitment 4 bytes signed 32-bit integer
? presence of field “blocks_per_roll_snapshot” 1 byte boolean (0 for false, 255 for true)
blocks_per_roll_snapshot 4 bytes signed 32-bit integer
? presence of field “blocks_per_voting_period” 1 byte boolean (0 for false, 255 for true)
blocks_per_voting_period 4 bytes signed 32-bit integer
? presence of field “time_between_blocks” 1 byte boolean (0 for false, 255 for true)
time_between_blocks Determined from data $X_5
? presence of field “endorsers_per_block” 1 byte boolean (0 for false, 255 for true)
endorsers_per_block 2 bytes unsigned 16-bit integer
? presence of field “hard_gas_limit_per_operation” 1 byte boolean (0 for false, 255 for true)
hard_gas_limit_per_operation Determined from data $Z.t
? presence of field “hard_gas_limit_per_block” 1 byte boolean (0 for false, 255 for true)
hard_gas_limit_per_block Determined from data $Z.t
? presence of field “proof_of_work_threshold” 1 byte boolean (0 for false, 255 for true)
proof_of_work_threshold 8 bytes signed 64-bit integer
? presence of field “tokens_per_roll” 1 byte boolean (0 for false, 255 for true)
tokens_per_roll Determined from data $N.t
? presence of field “michelson_maximum_type_size” 1 byte boolean (0 for false, 255 for true)
michelson_maximum_type_size 2 bytes unsigned 16-bit integer
? presence of field “seed_nonce_revelation_tip” 1 byte boolean (0 for false, 255 for true)
seed_nonce_revelation_tip Determined from data $N.t
? presence of field “origination_size” 1 byte boolean (0 for false, 255 for true)
origination_size 4 bytes signed 31-bit integer in the range -1073741824 to 1073741823
? presence of field “block_security_deposit” 1 byte boolean (0 for false, 255 for true)
block_security_deposit Determined from data $N.t
? presence of field “endorsement_security_deposit” 1 byte boolean (0 for false, 255 for true)
endorsement_security_deposit Determined from data $N.t
? presence of field “block_reward” 1 byte boolean (0 for false, 255 for true)
block_reward Determined from data $N.t
? presence of field “endorsement_reward” 1 byte boolean (0 for false, 255 for true)
endorsement_reward Determined from data $N.t
? presence of field “cost_per_byte” 1 byte boolean (0 for false, 255 for true)
cost_per_byte Determined from data $N.t
? presence of field “hard_storage_limit_per_operation” 1 byte boolean (0 for false, 255 for true)
hard_storage_limit_per_operation Determined from data $Z.t
? presence of field “hard_gas_limit_to_pay_fees” 1 byte boolean (0 for false, 255 for true)
hard_gas_limit_to_pay_fees Determined from data $Z.t
? presence of field “protocol_revision” 1 byte boolean (0 for false, 255 for true)
protocol_revision 4 bytes signed 31-bit integer in the range -1073741824 to 1073741823
? presence of field “max_operation_ttl” 1 byte boolean (0 for false, 255 for true)
max_operation_ttl 4 bytes signed 31-bit integer in the range -1073741824 to 1073741823
? presence of field “initial_endorsers” 1 byte boolean (0 for false, 255 for true)
initial_endorsers 4 bytes signed 31-bit integer in the range -1073741824 to 1073741823
? presence of field “delay_per_missing_endorsement” 1 byte boolean (0 for false, 255 for true)
delay_per_missing_endorsement 8 bytes signed 64-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
protocol_actions Variable sequence of $X_6
? presence of field “allow_collect_call” 1 byte boolean (0 for false, 255 for true)
allow_collect_call 1 byte boolean (0 for false, 255 for true)

X_7 (Determined from data, 8-bit tag)

Dune_activate_protocol (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
level 4 bytes signed 32-bit integer
? presence of field “protocol” 1 byte boolean (0 for false, 255 for true)
protocol 32 bytes bytes
? presence of field “protocol_parameters” 1 byte boolean (0 for false, 255 for true)
protocol_parameters Determined from data $X_4

Dune_manage_accounts (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
bytes Variable bytes

Dune_manage_account (tag 2)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
? presence of field “target” 1 byte boolean (0 for false, 255 for true)
target Determined from data $X_3
# bytes in next field 4 bytes unsigned 30-bit integer
options Variable bytes

Dune_clear_delegations (tag 3)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

scripted.opt_or_hash (Determined from data, 8-bit tag)

No_script (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

Script_hash (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
code_hash 32 bytes bytes
# bytes in next field 4 bytes unsigned 30-bit integer
storage Variable bytes

Script_code_hash (tag 2)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
code Variable bytes
code_hash 32 bytes bytes
# bytes in next field 4 bytes unsigned 30-bit integer
storage Variable bytes

Full_script (tag 255)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
code Variable bytes
# bytes in next field 4 bytes unsigned 30-bit integer
storage Variable bytes

contract_id (22 bytes, 8-bit tag)

Implicit (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Signature.Public_key_hash 21 bytes $public_key_hash

Originated (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Contract_hash 20 bytes bytes
padding 1 byte padding

entrypoint (Determined from data, 8-bit tag)

default (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

root (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

do (tag 2)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

set_delegate (tag 3)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

remove_delegate (tag 4)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Unnamed field 0 0 bytes placeholder (not actually present in the encoding)

named (tag 255)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
# bytes in next field 1 byte unsigned 8-bit integer
Unnamed field 0 Variable bytes

X_8

Name Size Contents
entrypoint Determined from data $entrypoint
# bytes in next field 4 bytes unsigned 30-bit integer
value Variable bytes

N.t

A variable length sequence of bytes, encoding a Zarith number. Each byte has a running unary size bit: the most significant bit of each byte tells is this is the last byte in the sequence (0) or if there is more to read (1). Size bits ignored, data is then the binary representation of the absolute value of the number in little endian order.

Name Size Contents
N.t Determined from data bytes

public_key (Determined from data, 8-bit tag)

Ed25519 (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Ed25519.Public_key 32 bytes bytes

Secp256k1 (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Secp256k1.Public_key 33 bytes bytes

P256 (tag 2)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
P256.Public_key 33 bytes bytes

public_key_hash (21 bytes, 8-bit tag)

Ed25519 (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Ed25519.Public_key_hash 20 bytes bytes

Secp256k1 (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
Secp256k1.Public_key_hash 20 bytes bytes

P256 (tag 2)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
P256.Public_key_hash 20 bytes bytes

fitness.elem

Name Size Contents
# bytes in next field 4 bytes unsigned 30-bit integer
Unnamed field 0 Variable bytes

block_header.alpha.full_header

Name Size Contents
level 4 bytes signed 32-bit integer
proto 1 byte unsigned 8-bit integer
predecessor 32 bytes bytes
timestamp 8 bytes signed 64-bit integer
validation_pass 1 byte unsigned 8-bit integer
operations_hash 32 bytes bytes
# bytes in field “fitness” 4 bytes unsigned 30-bit integer
fitness Variable sequence of $fitness.elem
context 32 bytes bytes
priority 2 bytes unsigned 16-bit integer
proof_of_work_nonce 8 bytes bytes
? presence of field “seed_nonce_hash” 1 byte boolean (0 for false, 255 for true)
seed_nonce_hash 32 bytes bytes
signature 64 bytes bytes

inlined.endorsement.contents (5 bytes, 8-bit tag)

Endorsement (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
level 4 bytes signed 32-bit integer

inlined.endorsement

Name Size Contents
branch 32 bytes bytes
operations 5 bytes $inlined.endorsement.contents
signature Variable bytes

operation.alpha.contents (Determined from data, 8-bit tag)

Endorsement (tag 0)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
level 4 bytes signed 32-bit integer

Seed_nonce_revelation (tag 1)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
level 4 bytes signed 32-bit integer
nonce 32 bytes bytes

Double_endorsement_evidence (tag 2)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
op1 Variable $inlined.endorsement
# bytes in next field 4 bytes unsigned 30-bit integer
op2 Variable $inlined.endorsement

Double_baking_evidence (tag 3)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
bh1 Determined from data $block_header.alpha.full_header
# bytes in next field 4 bytes unsigned 30-bit integer
bh2 Determined from data $block_header.alpha.full_header

Activate_account (tag 4)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
pkh 20 bytes bytes
secret 20 bytes bytes

Proposals (tag 5)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
period 4 bytes signed 32-bit integer
# bytes in next field 4 bytes unsigned 30-bit integer
proposals Variable sequence of bytes

Ballot (tag 6)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
period 4 bytes signed 32-bit integer
proposal 32 bytes bytes
ballot 1 byte signed 8-bit integer

Reveal (tag 107)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
fee Determined from data $N.t
counter Determined from data $N.t
gas_limit Determined from data $N.t
storage_limit Determined from data $N.t
public_key Determined from data $public_key

Transaction (tag 108)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
fee Determined from data $N.t
counter Determined from data $N.t
gas_limit Determined from data $N.t
storage_limit Determined from data $N.t
amount Determined from data $N.t
destination 22 bytes $contract_id
? presence of field “parameters” 1 byte boolean (0 for false, 255 for true)
parameters Determined from data $X_8

Origination (tag 109)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
fee Determined from data $N.t
counter Determined from data $N.t
gas_limit Determined from data $N.t
storage_limit Determined from data $N.t
balance Determined from data $N.t
? presence of field “delegate” 1 byte boolean (0 for false, 255 for true)
delegate 21 bytes $public_key_hash
script Determined from data $scripted.opt_or_hash

Delegation (tag 110)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
fee Determined from data $N.t
counter Determined from data $N.t
gas_limit Determined from data $N.t
storage_limit Determined from data $N.t
? presence of field “delegate” 1 byte boolean (0 for false, 255 for true)
delegate 21 bytes $public_key_hash

Dune_manager_operation (tag 201)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
fee Determined from data $N.t
counter Determined from data $N.t
gas_limit Determined from data $N.t
storage_limit Determined from data $N.t
# bytes in next field 4 bytes unsigned 30-bit integer
Unnamed field 0 Determined from data $X_7

Transaction (tag 203)

Name Size Contents
Tag 1 byte unsigned 8-bit integer
source 21 bytes $public_key_hash
fee Determined from data $N.t
counter Determined from data $N.t
gas_limit Determined from data $N.t
storage_limit Determined from data $N.t
amount Determined from data $N.t
destination 22 bytes $contract_id
parameters Determined from data $X_0
? presence of field “collect_call” 1 byte boolean (0 for false, 255 for true)
collect_call Determined from data $X_2