Relayer API

GET /tree

How to read the pool's commitment tree, its encrypted note memos and its spent nullifiers to find notes and prove against a root.

GET /tree returns the pool's whole commitment tree: every leaf with its encrypted memo, the current root and every spent nullifier. The browser reads it to find the holder's notes (by trying to decrypt each memo with the view key), to drop notes already spent, and to compute the Merkle path for each note it spends before proving a pay or unshield. See Notes and the pool.

Request

HTTP
GET /tree

The route takes no parameters.

Response

TreeResponse
depthrequired
26
The tree's depth: room for 2^26 leaves.
rootrequired
Field
The root over every leaf below, in leaf order. Prove against this root.
nextLeafIndexrequired
integer
The index the next commitment takes, 0 to 67108864. Equal to the number of leaves.
leavesrequired
TreeLeaf[]
Every leaf, ascending by leafIndex.
nullifiersrequired
Field[]
Every nullifier spent so far.
TreeLeaf
leafIndexrequired
integer
The leaf's position, 0 to 67108863.
commitmentrequired
Field
The note commitment.
memorequired
Memo
The note's encrypted memo, as sent with the shield, pay or unshield that inserted it. Base64 of at most 108 characters, decoding to at most 80 bytes.

Behaviour

The relayer answers from its index of the program's transactions. When it is ready, it first indexes any new ones, so a shield, pay or unshield that has confirmed is in the answer. Leaves are appended by POST /shield/confirm, POST /pay and POST /unshield: each inserts exactly two, a zero-valued output included. A leaf is never removed or reordered, so a client that has read the tree once can keep its leaves and compare nextLeafIndex.

Empty positions hash as zero. The tree is a depth-26 Poseidon tree, the one the circuit proves membership in; an empty tree has the root:

Text
0x120c58f143d491e95902f7f5277778a2e0ad5168f6add75669932630ce611518

A note is spent when its nullifier is in nullifiers. A root read here is accepted by pay and unshield until the pool stops accepting it; a proof against a root it no longer accepts answers UNKNOWN_ROOT, and the caller reads the tree again.

Errors

The route raises no code of its own and does not wait for readiness. Codes common to every route, such as ORIGIN_NOT_ALLOWED, and UPSTREAM_UNAVAILABLE when the Solana RPC fails while indexing, are under Errors.

Example

HTTP
GET /tree
Accept: application/json