Skip to content

Instantly share code, notes, and snippets.

@luca-moser
Last active July 9, 2020 17:19
Show Gist options
  • Save luca-moser/e3afd2ff5af2e6c1374a4135629b28aa to your computer and use it in GitHub Desktop.
Save luca-moser/e3afd2ff5af2e6c1374a4135629b28aa to your computer and use it in GitHub Desktop.

Chrysalis Message Structure (Table Notation)

Notation
Schemas:
  • oneOf – one of the mentioned subschemas.
  • optOneOf – optionally one of the mentioned subschemas.
  • anyOf – any (one or more) of the defined subschemas.
Data Types:
  • byte - An unsigned 8-bit integer.
  • varint - A numerical value using N amount of bytes needed to represent its value. Equivalent on how it works in Protobuffers.
  • ByteArray - An array of bytes.
  • ByteArray[N] - An array of N amount of bytes.
Name Type Description
Version byte/varint The message version.
Parent #1 ByteArray[32] The hash of the first parent this Message references.
Parent #2 ByteArray[32] The hash of the second parent this Message references.
Payload (oneOf)
Signed Transaction Payload
Describes a signed atomic transaction moving funds.
Name Type Description
Payload Type byte Set to value 0 to denote a Signed Transaction payload.
Payload Length varint The length in bytes of the signed transaction.
Transaction (anyOf)
Unsigned Transaction
Describes the essence data making up a transaction by defining its inputs and outputs and an optional payload.
Name Type Description
Transaction Type byte/varint Set to value 0 to denote an Unsigned Transaction.
Inputs Count byte/varint The amount of inputs proceeding.
Inputs (anyOf)
UTXO Input
Describes an input which references an unspent transaction output to consume.
Name Type Description
Input Type byte/varint Set to value 0 to denote a UTXO Input.
Transaction ID ByteArray[64] The transaction reference from which the UTXO comes from.
Transaction Output Index byte/varint The index of the output on the referenced transaction to consume.
Unlock Index byte/varint The index of the unlock block unlocking the funds used in this input. Multiple inputs can reference the same unlock block, for example, inputs consuming multiple UTXOs residing on a specific Ed25519 address may reference the same signature unlock block with the corresponding signature unlocking the funds.
Unlock Mode byte/varint Defines the unlock block's type which unlocks this input.
Name Value Description
SIGNATURE 1 A signature unlock block unlocks this input.
Outputs Count byte/varint The amount of outputs proceeding.
Outputs (anyOf)
SigLockedSingleDeposit
Describes a deposit to a single address which is unlocked via a signature.
Name Type Description
Output Type byte/varint Set to value 0 to denote a SigLockedSingleDeposit.
Address (oneOf)
Ed25519 Address
Name Type Description
Address Type byte/varint Set to value 0 to denote an Ed25519 Address.
Address ByteArray[32] The raw bytes of the Ed25519 address which is a BLAKE2b-256 hash of the Ed25519 public key.
WOTS Address
Name Type Description
Address Type byte/varint Set to value 1 to denote a WOTS Address.
Address ByteArray[49] The T5B1 encoded WOTS address.
Amount uint64 The amount of tokens to deposit with this SigLockedSingleDeposit output.
Payload (oneOf)
Indexation Payload
Describes a payload which is used to instruct the node to index the Message of which it is part of.
Name Type Description
Payload Type byte/varint Set to value 4 to denote an Indexation payload.
Payload Length byte/varint The length in bytes of the Indexation payload.
Tag ByteArray[16] The tag which is used to index the Signed Transaction's hash.
Unlock Blocks Count byte/varint The count of unlock blocks proceeding.
Unlock Blocks (anyOf)
Ed25519 Signature Unlock Block
Name Type Description
Signature Type byte/varint Set to value 0 to denote an Ed25519 Signature Unlock Block.
Public key ByteArray[32] The public key of the Ed25519 keypair which is used to verify the signature.
Signature ByteArray[64] The signature signing the serialized Unsigned Transaction.
WOTS Signature Unlock Block
Name Type Description
Signature Type byte/varint Set to value 1 to denote a WOTS Signature Unlock Block.
Signature Length byte/varint Denotes the length of the WOTS signature proceeding.
Signature ByteArray The signature signing the serialized Unsigned Transaction.
Milestone Payload
Describes a Milestone which is issued by the Coordinator.
Name Type Description
Payload Type byte/varint Set to value 1 to denote a Milestone payload.
Payload Length byte/varint The length in bytes of the Milestone.
Index byte/varint The index of the Milestone.
Inclusion Merkle Proof ByteArray[64] Specifies the merkle proof which is computed out of all the tail tx hashes of txs which mutated the ledger state with this Milestone. RFC
Signature Length byte/varint The length of the proceeding Milestone signature.
Signature ByteArray The signature signing the entire Message excluding the nonce and the signature itself.
Unsigned Data Payload
Describes a payload with data without any specification what the data means.
Name Type Description
Payload Type byte/varint Set to value 2 to denote an Unsigned Data payload.
Payload Length byte/varint The length in bytes of the Unsigned Data payload.
Data ByteArray The data of the Unsigned Data payload.
Signed Data Payload
Describes a payload with signed data (and its corresponding Ed25519 public key and signature) without any specification what the data means.
Name Type Description
Payload Type byte/varint Set to value 3 to denote an Signed Data payload.
Payload Length byte/varint The length in bytes of the Signed Data payload.
Data ByteArray The data of the Signed Data payload.
Public Key ByteArray[32] The Ed25519 public key used to verify the signature.
Signature ByteArray[64] The signature signing the data.
Indexation Payload
Describes a payload which is used to instruct the node to index the Message of which it is part of.
Name Type Description
Payload Type byte/varint Set to value 4 to denote an Indexation payload.
Payload Length byte/varint The length in bytes of the Indexation payload.
Tag ByteArray[16] The tag which is used to index the Message's hash.
Nonce uint64 The nonce which lets this message fulfill the Proof-of-Work requirement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment