Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The model in one page

An account is a nonce plus a map from program account ids to byte strings. Each entry in that map is the state of one actor: a pair of an account and a program. “Alice’s token actor” means the token program’s state on Alice’s account.

A transaction delivers one root message to one actor. The program’s handler runs with that actor’s state and the message, and returns an optional new state, synchronous and asynchronous messages, events and validity windows (one over block heights, one over timestamps).

A handler sees its own state on one account, plus the message, its sender and the grants it carries, and nothing else. To affect another actor it sends a message, and the receiver decides what to do with it.

A SyncMessage is delivered inside the same transaction, and if anything in it fails the whole transaction fails. An AsyncMessage to an actor the transaction can run (a public actor it declares, or one of the submitter’s own private actors when the submitter asks for it) is also delivered in the transaction, and if it fails the whole transaction fails (AsyncMessage). An AsyncMessage to another private address is stored on chain for its owner to collect later, in their own transaction, with their own proof.

Handlers of public actors run on the sequencer. Handlers of private actors run on the owner’s machine inside a zero-knowledge proof, and the sequencer checks the proof and runs the public side of the messages that crossed, without seeing the private state.

A program, by default, does not learn whether the accounts it was given are public or private. The same bytecode runs either way. Privacy, in the default case, is a property of the transaction, not of the program.

Properties

Four properties follow, and the designs in the catalog rest on them.

Public and private actors work together: since a program can serve both kinds of account, its public and private actors can exchange messages. A private balance pays a public pool in one transaction, and a public treasury pays a private member at a registered address through a stored message, without a separate shielded pool or a bridge between the two.

A program only reasons about itself, so you can audit a handler on its own, given which senders and reply formats it trusts.

A message can wait. An AsyncMessage addressed to a stranger’s private account sits on chain until its owner collects it, so a public program can pay a private person who is offline.

A private actor’s message is backed by its code: the proof covers the handler that produced it, so a public actor of the same program can trust the message as a statement about state it cannot see.

Terms used throughout

A declared actor is one the transaction lists as a public actor its execution may reach. The engine runs a public handler only for a declared actor (Declaring actors).

Settlement is the sequencer applying a transaction to live state in a block: its public handlers run, a private transaction’s private actions are recorded, and the fee is charged. Settlement decides whether a transaction takes effect; finality decides whether that can still be undone.

A witness is the evidence that a transaction may use an account. For a public signer it is a signature and a commitment to the account’s next key, carried in the transaction (Keys, nonces and rotation). For a private account it is what the prover holds to use the account (its key, the proof the account’s current version is on chain, the address openings it presents), an input to the proof that never leaves the prover’s machine (Authorization).

A fee fallback is a fee-only version of a private payer’s action, proven alongside the real one. If the public part fails at settlement, the sequencer applies it instead, so the fee is still paid. A proof carries one only when the payer held the whole reserve before the transaction ran; without it, and without a public signer paying, a failed public part leaves the transaction dropped and unpaid (Private fees).

To shield is to move native tokens from a public account into a private one; to deshield is the reverse. These are wallet words: to the protocol both are private transactions.

A mention is a wallet library term, not a protocol one: one account a client lists for a private transaction, with the program whose actor on it is meant and whether the account authorizes (Submitting a private transaction).

Where to go from here

Build on LEZ starts from an empty shell and ends with a program you wrote running on chain. Accounts, actors and state covers this page at full depth.