Skip to content

Latest commit

 

History

History
48 lines (30 loc) · 2.32 KB

encoding.md

File metadata and controls

48 lines (30 loc) · 2.32 KB

Encoding

The ledger

Most of the data in Namada are encoded with Borsh, except for the outer layer of transactions that are being passed via Tendermint and therefore are required to be encoded with protobuf.

Borsh binary encoding

The encoding schemas below are described in terms of Borsh specification, following the general principles (verbatim from Borsh):

  • integers are little endian;
  • sizes of dynamic containers are written before values as u32;
  • all unordered containers (hashmap/hashset) are ordered in lexicographic order by key (in tie breaker case on value);
  • structs are serialized in the order of fields in the struct;
  • enums are serialized with using u8 for the enum ordinal and then storing data inside the enum value (if present).

Note that "nil" corresponds to unit (()) which is encoded as empty bytes (nothing is being written).

{{#include encoding/generated-borsh-spec.md}}

Protobuf

The schemas below are described in terms of proto3 specification.

All the data fields are REQUIRED, unless specified otherwise.

Transactions

Transactions MUST be encoded in the format as defined for message Tx.

Note that for the default transactions, the data are encoded with Borsh.

Name Type Description Field Number
code bytes Transaction WASM code. 1
data optional bytes Transaction data (OPTIONAL). 2
timestamp google.protobuf.Timestamp Timestamp of when the transaction was created. 3

Proto definitions

{{#include ../../../../proto/types.proto}}
<style> table { margin-left:0; } </style>