Skip to content
Open app

Run an association set

Register a set, serve its manifest, and publish roots of the deposit labels you approve.

Any wallet can run a set and decide which deposits it approves. Holders then pick it for a spend, and venues list it among the sets they accept. See Association Set Providers for what a set is.

1. Serve a manifest

Pick a URL of up to 512 bytes, over http or https, where you will serve the set's manifest: a JSON document with your set's name, policy line and authority, and, once you publish, the root and the ordered leaves it covers.

manifest.json
{
  "name": "Your set's name",
  "policy": "One line on what this set approves.",
  "authority": "the wallet that will publish roots",
  "root": "the current root",
  "leaves": ["every approved label, in tree order"]
}

2. Register the set

sh
node cli/plaza.mjs asp register --keypair ./asp.json --name "Your set" --manifest https://example.org/manifest.json

In the app:

  1. Open /sets. In the Run a set box, connect the wallet that will publish roots. It becomes the set's authority.
  2. Enter Name (up to 96 characters) and Manifest URI.
  3. Press Register set and approve the transaction.

The set's id is its ASP account, derived from ["asp", authority], so one wallet runs one set. The set appears on /sets with no root yet.

3. Choose labels

Read new deposits from the API or from the program's Deposited events. Each carries the depositor, mint, amount, slot, nonce and label, so you can screen the depositor and recompute the label. Keep the ordered list of every label you approve: each publish covers the whole list, not only the new ones.

4. Build the root

The root is a depth-32 Poseidon tree over your list; see Association sets. The SDK builds it:

root.ts
import { AssociationTree, initializePoseidon } from '@plaza/sdk'

declare const approved: bigint[] // every label you approve, in your order

await initializePoseidon()
const tree = new AssociationTree(approved)
console.log(tree.root.toString())

5. Publish

Update the manifest at your registered URL with the new root and leaves, then publish. The API refuses to build the publish unless the manifest's leaves equal the leaves you send. With the CLI, put the same leaves in a file as a JSON array of decimal strings:

sh
node cli/plaza.mjs asp publish --keypair ./asp.json --leaves ./leaves.json --manifest https://example.org/manifest.json

The CLI builds the root from the file, fetches the manifest, refuses if its leaves differ from the file, and sends the SHA-256 of the manifest bytes as manifest_hash. Pass --manifest-hash to give the hash yourself.

In the app:

  1. Open your set's page, /sets/ followed by the set's id, and connect the authority wallet. The Operator box opens.
  2. Paste the root into Root and the approved labels into Leaves, one per line, in the order you built the tree from.
  3. Check Manifest URI and press Publish root.

The program appends the root to your window of 32 and the API serves the leaves, which holders download to build their proofs. Your root history shows each root, its members, slot, time, and whether it is still In window.

Dropping a label

Clear your window, then publish a root without the label. clear_roots empties the window, so the label stops proving in your set as soon as the transaction lands. Published alone, the new root leaves the label provable against your older roots until 32 more publishes push them out.

Update the manifest with the new root and leaves first, as for any publish. Then send both instructions in one transaction signed by the authority, clear_roots first, so your window is never empty between the two:

drop.ts
import { AssociationTree, clearRootsInstruction, fieldBytes, initializePoseidon, publishRootInstruction } from '@plaza/sdk'
import type { Address } from '@solana/kit'

declare const authority: Address // your set's authority
declare const approved: bigint[] // your list without the dropped label
declare const manifestHash: Uint8Array // SHA-256 of the updated manifest, 32 bytes

await initializePoseidon()
const tree = new AssociationTree(approved)
const instructions = [
  await clearRootsInstruction(authority),
  await publishRootInstruction(authority, fieldBytes(tree.root), approved.length, manifestHash),
]

The program emits RootsCleared, and your root history shows every earlier root out of the window. A holder who proved against one of them sees RootOutsideWindow and proves again against the new root.