Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Share registry internals

This page describes the share registry the SDK uses underneath sharing on-chain: how it stores a share, what posting costs, how a label is checked, and the byte layout of the labels. Sharing and labelling through client.acp needs none of it. Unless you write your own registry client or label encoder, or build sharing features the SDK does not offer, you should not need to work with any of this directly.

How the registry keeps a share

The registry keeps in storage only what it checks itself — the share header: issuer, expiration, recipient, revoker, and the block of the share's Shared event. The full payload and its metadata travel in that event:

event Shared(address indexed recipient, address indexed issuer, bytes32 indexed shareId, ACP acp, bytes metadata);

getIncomingShares reads the headers with sharesFor (one call, filtered for expiry and revocation on-chain), then the events with one single-block getLogs per block, filtered by the share ids — a query any node answers, however old the block. If a share was removed and posted again within one block, that block holds two of its events; the later one is the share. Contracts keep isShareValid(shareId); they cannot read a share's handles. Removing a share deletes its header; its event stays in its block, and readers no longer find it. Each share is read on its own: when a node cannot serve a block yet, or an event does not hash to its share id, readSharesFor lists that share as unreadable with the reason, and getIncomingShares leaves it out, so one share never hides the rest.

Gas

Gas of share(acp, metadata), measured on Arbitrum Sepolia with ACPs as the SDK creates them (default revoker and creation timestamp set). L2 execution gas; the L1 data part depends on the calldata.

ShareWithout labelsWith labels
1 ctHash186k187k (36-byte blob)
7 ctHashes191k194k (122-byte blob)
20 ctHashes201k207k (288-byte blob)
100 ctHashes265k291k (1,248-byte blob)

A recipient's first share costs about 17k more (it starts their list).

How a label is checked

  • A stored value is checked by repeating the view call at the labelled block: the returned word must be the ctHash. Once no node keeps the state of that block, the check returns unverifiable (an archive node is needed for old blocks).
  • An event value is checked against the log at the labelled block and log index: it must come from the labelled contract and transaction, its topic0 must start with the labelled selector, and the ctHash must be one of its topics or data words. Free nodes answer single-block log queries for blocks years old.

Requests are shared across the labels of one share: one getLogs per contract and block however many values it carries, and one call per distinct stored read.

Layout

One blob per share, version 0x03. Contracts, selectors and transactions are listed once; each entry points to them by position. Entries follow the order of the share's handles. Integers are big-endian; sizes in bytes.

blob = version (1)
     | contracts:     count (1), 20 bytes each
     | selectors:     count (1), 4 bytes each      function selectors, and event selectors (first 4 bytes of topic0)
     | transactions:  count (1), 6 bytes each      block (4), tx index (2)
     | entries: one per handle, in the share's order
     | app key, optional: 0x01, key (32)          keccak256 of the app's name; absent when the blob ends

stored value = 0x00 | contract (1) | selector (1) | block (4) | args                    8 bytes or more
event value  = 0x01 | contract (1) | transaction (1) | log index (2) | selector (1)     6 bytes
unlabelled   = 0xff                                                                     1 byte

args     = 0x00                                 no arguments
         | 0x01                                 one argument: the share issuer
         | 0xff | return word (1) | count (1) | argument, count times
argument = 0x00 | word (32)                     a literal ABI word
         | 0x01                                 the share issuer

A real share on Arbitrum Sepolia — two balances and five transfer amounts from four transactions — is 122 bytes:

03                                           version 3
02                                           2 contracts
   389be1eb842290f264a6851f49c0149b8035a052     [0] fUSD
   06a52cf2e0ceafc7d1f522400500ca7f3df18754     [1] fUSDy
02                                           2 selectors
   344ff101                                     [0] confidentialBalanceOf(address)
   67500e8d                                     [1] ConfidentialTransfer(address,address,bytes32)
04                                           4 transactions
   12ba9304 0005                                [0] block 314217220, tx 5
   12ba9307 0008                                [1] block 314217223, tx 8
   12ba9309 000a                                [2] block 314217225, tx 10
   12ba9375 000c                                [3] block 314217333, tx 12

00 00 00 12bb9d0f 01      stored value: fUSD, confidentialBalanceOf(issuer) at block 314285327
00 01 00 12bb9d0f 01      stored value: fUSDy, confidentialBalanceOf(issuer) at block 314285327
01 00 00 001e 01          event value: fUSD, transaction 0, log 30, ConfidentialTransfer
01 00 01 0041 01          event value: fUSD, transaction 1, log 65, ConfidentialTransfer
01 00 02 008a 01          event value: fUSD, transaction 2, log 138, ConfidentialTransfer
01 00 03 006a 01          event value: fUSD, transaction 3, log 106, ConfidentialTransfer
01 01 03 0073 01          event value: fUSDy, transaction 3, log 115, ConfidentialTransfer

A share posted by a client configured with acp: { app } ends with 01 and the app's 32-byte key, 155 bytes for this sample. The last two are the two values of one vault deposit and share its transaction. The fUSDy amount appears in two logs of that transaction (115 and 118); the label names the ConfidentialTransfer, and a check against log 118 fails on its selector.

Limits. 255 contracts, selectors and transactions per share (one-byte counts and positions); blocks up to 4.29 billion; 65,535 transactions per block and logs per block; stored-value arguments are static 32-byte words only.

Disclosure. A label names one log. Where a ctHash appears in several logs, the label points at the one the issuer chose; the recipient learns that log's other parameters too.

The format speaks of contracts, selectors and positions in the chain only; it knows nothing of tokens. encodeShareMetadata and decodeShareMetadata in @cofhe/sdk/acps read and write it.