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
GET /treeThe route takes no parameters.
Response
depthrequired26rootrequiredFieldnextLeafIndexrequiredintegerleavesrequiredTreeLeaf[]leafIndex.nullifiersrequiredField[]leafIndexrequiredintegercommitmentrequiredFieldmemorequiredMemoshield, 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:
0x120c58f143d491e95902f7f5277778a2e0ad5168f6add75669932630ce611518A 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
GET /tree
Accept: application/jsonconst tree = await client.tree()
const spent = new Set(tree.nullifiers)