On-chain protocols for developers
Developers12.5.9+

On-chain protocols for developers

eMPP, RANK, ENTY, SLP, ALP, BLOB and the POOL record on one page: envelopes, byte layouts with checked examples, the gotchas that leave an output unindexed, test vectors.

Applications write data into OP_RETURN outputs; nodes index it. None of it is consensus: a malformed payload is a valid transaction that is simply not indexed. That makes mistakes silent, so check what you write with the node's dry-run routes before you sign (POST /api/v1/social/decode for RANK and ENTY, POST /api/v1/txs/token-check for tokens).

The full specification of each protocol is its own page in the protocol section; this page is the map, with the parts people get wrong.

The protocols #

ProtocolLOKAD idTransportIndexed bySpec
eMPPnone (carries the others)OP_RETURN OP_RESERVED (6a 50) + pushesemppeMPP
RANK votesRANK 52414e4bbare OP_RETURN (Format A or B) or eMPPrankRANK
ENTY entity registryENTY 454e5459eMPP onlyrankEntities
SLP v1 tokensSLP\0 534c5000bare OP_RETURN at output 0, or eMPPslpSLP
ALP tokensSLP2 534c5032eMPP at output 0 onlyalpALP
BLOB filesBLOB 424c4f42bare OP_RETURN or eMPPblobBLOB
POKR poker eventsPOKR 504f4b52bare OP_RETURN or eMPPpokrPOKR
POOL mining recordPOOL 504f4f4ceMPP in the coinbasepoolbelow and The pool
UTXO commitmentUTXO 5554584feMPP in the coinbase, from Napoleon (consensus)validationUTXO commitment
VOIX, BOOKVOIX 564f4958bare OP_RETURN or eMPPvoix, bookVOIX (off on mainnet)

GET /api/v1/modules says which modules a node runs and their versions; a module left out answers 503 module_disabled.

Size and count of OP_RETURN outputs #

RuleLotus (this node)
Size of one OP_RETURN script8,005 bytes, for relay and for block transactions (MAX_OP_RETURN_RELAY, -datacarriersize lowers it for relay)
OP_RETURN outputs per transactionat most 3 before Napoleon (multi-op-return); no limit from Napoleon
Warning

Upstream nodes (the 12.0.x line) refuse a block transaction whose OP_RETURN script is longer than 223 bytes. A transaction with a longer one is valid on Lotus and not on the upstream chain. RANK votes and most records are far below 223 bytes; BLOB chunks and long VOIX messages are not. See Napoleon for integrators.

eMPP in one paragraph #

6a 50, then one or more pushes; each push is a segment, LOKAD id (4 bytes) || payload. Pushes must be canonical: a direct push 01..4b for 1 to 75 bytes, 4c (PUSHDATA1) only for 76 to 255, 4d only for 256 to 65,535, 4e only above that. OP_0, OP_1..OP_16 or any other opcode make the whole output invalid. Any output of any transaction is scanned, the coinbase included, and several protocols can share one output.

RANK #

Three layouts carry the same vote: platform, profile, optional post, optional display name, sentiment.

Format A (multi-push): 6a, push RANK, OP_0 (negative) or OP_1 (positive) as a bare opcode, push of 1 platform byte, push profile, optional push post, optional push display name.

Text
6a 04 52414e4b 51 01 01 05 616c696365 08 0102030405060708
   "RANK"      +  twitter  "alice"    post id 72623859790382856 (big-endian uint64)

Format B (one push): 6a, one push of RANK || 01 (version) || sentiment (00/01) || lp platform name || lp profile || lp post || lp display name, lp being a 1-byte length:

Text
6a 3b 52414e4b 01 01 0d 6c6f63616c627573696e657373 15 736972656e652d3132333435363738393031323334 00 0f 4c6520546f6e6e6561752064274f72
      "RANK"   v1 +   "localbusiness"              "sirene-12345678901234"                   no post  "Le Tonneau d'Or"

eMPP: a segment RANK + the Format B body from the version byte on.

Both examples decode on a 12.5.9 node with POST /api/v1/social/decode (transports format_a, format_b).

Platform byteNameProfile idPost id
0x00lotusia (12.5.9)a Lotus address: 20-byte key hash or 33-byte Taproot commitment, raw bytes; REST shows lowercase hex and profileAddress32-byte hash
0x01twitterhandletweet id (Format A: 8-byte big-endian)
0x02nostrnpubnote id
0x03telegramnumeric id or handlemessage id
0x04pokeruser UUIDevent UUID
0x05localbusinessestablishment id, e.g. sirene-<SIRET>
0x06entity (12.5.9)eid, 26 characterscollection id (8 bytes in Format A, decimal string in Format B and eMPP)
0x07..0xffplatform_<n>Format A only

Gotchas:

  • Format A strips every 0x00 byte from the profile id, except for platform lotusia, where the bytes are a hash. Do not zero-pad ids.
  • Format B and eMPP name the platform by its name and reject unknown names; only Format A can carry platform_<n>.
  • The weight is the value of the OP_RETURN output. A vote below a node's -rankminburn (default 1 sat) is not indexed by that node.
  • Only the first decodable RANK segment of an output is a vote.

ENTY: the entity registry #

An entity id is computed, not claimed: eid = base32lower(SHA-256("lotus-entity-v1" || 0x00 || key)[0..16]), 26 characters. A vote on an entity is a RANK vote with platform entity and the eid as profile. The ENTY segment publishes the key behind an eid:

Text
6a 50 0f 454e5459 01 01 07 77643a51323433 02
      push 15  "ENTY" v1 REG len 7 "wd:Q243" kind 2 (place)
Keyeid
wd:Q24335wicsrcclf4w33gvcrhn2k64i
wd:Q90awcgivxwvgt2bwvxj3k7g3mjlq
fr-siret:73282932000074ygb3sggbc33laaqhji4bzxfwke
dns:example.com2wdfizeo7qbypvkv6lp25a4p74

A REG counts when the same output carries a RANK vote of at least 1 sat (the vote is the stake), or when the output burns at least 1,000 sats (REG_MIN_BURN). The standalone example above with a value of 0 registers nothing: social/decode answers below_reg_min_burn. Put the RANK segment first and the ENTY segments after it in the same eMPP output.

SLP and ALP #

Tokens as eCash specifies them (SLP v1 types 1, NFT1 group and child; ALP over eMPP at output 0 with value 0). The node validates every token transaction against its inputs and indexes balances, history and holders (/api/v1/slp/..., /api/v1/alp/...). A transaction that spends token outputs without a valid token payload burns them: broadcast through POST /api/v1/txs/broadcast-checked, or check first with POST /api/v1/txs/token-check. The Chronik API leaves the SLP fields empty (Chronik).

BLOB #

A file is split into chunks, one OP_RETURN output per chunk, and named by the SHA-256 of the whole file. Native chunk: exactly six pushes, integers big-endian:

Text
6a 04 424c4f42 20 <blob_id, 32 bytes> 04 <chunk_index u32 BE> 04 <total_chunks u32 BE> 01 <content type> <push payload>
Warning

Every field is a data push, even a one-byte one. The content type 0x01 (JSON) is written 01 01: push of one byte, then the byte. Script libraries that "minimally encode" small numbers turn it into OP_1 (0x51), and the BLOB decoder refuses OP_0, OP_1..OP_16 and OP_1NEGATE anywhere in the output: the whole chunk is then not indexed, silently. Build the pushes by hand. The same holds for the PUSHDATA forms: 4c only from 76 bytes, 4d only from 256.

Content types: 01 JSON, 02 SVG, 03 WebP, 04 gzipped JSON, 05 PNG, 06 JPEG, 07 text, 08 bytes. A chunk carries up to 7,951 bytes of payload in an 8,005-byte script. The file is served once every chunk is in and the SHA-256 matches (GET /api/v1/blob/<id>/chunks, GET /api/v1/blob/tx/<txid>).

POOL record #

A block mined by a Lotus pool node describes its payout in extra OP_RETURN outputs of the coinbase, in eMPP, LOKAD POOL. Addresses and amounts are not repeated: they are the coinbase outputs. Each segment is POOL || 01 (version) || lp section type || body, integers little-endian, like ALP.

SectionBody
H (head)u8 flags (bit 0 fallback, 1 payee list truncated, 2 continued) · lp pool_id · u8 finder_node · 8 bytes window_commit · u32 window_shares · u64 window_weight · u16 pool_hashrate · u16 payee_total · u16 fee_bps · u16 burn_bps
P (payees)u16 first_vout · u8 n · n × (u16 share, u16 hashrate)
B, Cu64: satoshis burnt for work without a Lotus address, and rounding burnt instead of overpaying
Sa ledger settlement (pool operators only)

share is floor(65535 × weight / total); hashrates are 2^(v / 1024) H/s. Unknown section types are kept, never rejected: skip them. Mainnet block 00000000014254ebc30bcda4defc8ebd1d37e8688627c16f0ae97083a24c9445, coinbase output 18:

Text
6a 50 2f 504f4f4c 01 01 48 00 09 4652454e4348425443 7d 781e17bf7014bb53 33040000 e366b3d9a7020000 5381 1000 0000 0100
         "POOL"   v1 "H"  flags "FRENCHBTC"          125 window commit    1075 shares weight 2919935207139 hashrate 33107 16 payees fee 0 burn 1 bps
      4a 504f4f4c 01 01 50 0100 10 3533 5f78 5031 1b78 ...
         "POOL"   v1 "P"  vout 1, 16 payees: (13109, 30815), (12624, 30747), ...

GET /api/v1/pool-public/record/<block hash> and decodepoolrecord give the decoded record.

Test vectors #

In the lotusd source tree, generated by the code that the node and the JavaScript encoders are tested against:

FileContent
src/test/data/entity_vectors.jsonKeys, eids, cids, key refusals with their reason, ENTY records, outputs, votes
src/test/data/rank_vote_vectors.jsonRANK votes in every layout
src/test/data/rank_score_vectors.jsonscore_v1
doc/voix/vectors/*.jsonVOIX records, names, sealing, onion packets
Source share/www/docs/protocols-dev.md in the lotusd repository
Checked against doc/protocols/README.md doc/protocols/empp.md doc/protocols/rank.md doc/protocols/entity.md doc/protocols/blob.md src/modules/blob/blob_module.cpp src/modules/rank/rank_module.cpp src/modules/rank/rank_entity.cpp src/pool/record.h doc/pool-payouts.md src/policy/policy.h src/script/standard.h src/test/data/entity_vectors.json