Reference

Instructions

Every instruction of the once program, with its arguments, accounts, event and errors.

Arguments and accounts are listed in the order the program takes them. Each instruction emits its event through Anchor's emit_cpi!, so the event and authority accounts close every list. Field elements are 32 bytes big-endian; integers are little-endian as Anchor encodes them; times are Unix seconds in UTC.

The program's address on the localnet is ByJWamQ4FndMu5Kio7mFZHKuvgavZz5bYJZKBLMziojN.

enroll

Verifies an enrollment proof, creates or reactivates the person account keyed by the person nullifier, and appends the leaf to the person tree.

Signed by: The enrolling wallet. Discriminator 3a0c24038e1c012b.

Arguments

NameTypeDescription
nrequired[u8; 32]The person nullifier N, 32 bytes big-endian.
leafrequired[u8; 32]The leaf Poseidon(s, k, expiry), 32 bytes big-endian.
valid_untilrequiredu64The credential’s valid-until time, Unix seconds. Must be in the future.
key_versionrequiredu64The OPRF registry version the proof was made against. Must equal the current version.
proofrequiredProofThe Groth16 proof of the enroll circuit.

Accounts

NameTypeDescription
walletsigner · writableThe enrolling wallet. It pays the rent and the fee, and is the only wallet that can revoke.
personwritable · PDA ["person", n]The person account at ["person", n].
issuerreadThe issuer account of the credential’s issuer. Absent or retired gives UnknownIssuer.
oprfPDA ["oprf"]The OPRF registry.
treewritable · PDA ["tree"]The person tree.
system_program11111111111111111111111111111111The System Program.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits Enrolled. Can fail with AlreadyEnrolled, CredentialExpired, InvalidField, ProofInvalid, RevokeCooldown, StaleOprfKey, TreeFull, UnknownIssuer.

revoke

Replaces the person’s leaf with zero, records the new root and marks the person account revoked.

Signed by: The enrolling wallet. Discriminator aa171f2285ad5df2.

Arguments

NameTypeDescription
nrequired[u8; 32]The person nullifier N.
siblingsrequired[[u8; 32]; 20]The 20 sibling hashes from the leaf to the current root, leaf level first.

Accounts

NameTypeDescription
walletsignerThe wallet recorded in the person account.
personwritable · PDA ["person", n]The person account at ["person", n].
treewritable · PDA ["tree"]The person tree.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits Revoked. Can fail with NotEnrolled, RootUnknown.

create_scope

Opens a drop or a poll under the next scope ID. A drop is funded into Rings and pays the protocol fee in the same instruction; a poll takes its relay budget.

Signed by: The creator. Discriminator 8552b337da6468e6.

Arguments

NameTypeDescription
termsrequiredTermsThe scope’s terms. See Terms.
rings_datarequiredVec<u8>Empty. The deposit is built inside the instruction.

Accounts

NameTypeDescription
creatorsigner · writableThe creator. Funds the scope and pays the rent.
configwritable · PDA ["config"]The config account. Its next scope ID becomes this scope’s ID.
scopewritable · PDA ["scope", config_next_scope_id]The new scope account at ["scope", id].
pool_authorityreadThe pool authority PDA at ["pool"], the owner of the drop’s pool note.
system_program11111111111111111111111111111111The System Program.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits ScopeCreated. Can fail with ArithmeticOverflow, BadPoolNote, InvalidScope.

A drop passes the fee destination first in its remaining accounts, then the SPP deposit accounts: for SOL [tree, creator, SPP, system program, SOL interface], for USDC [tree, creator, SPP, token program, mint, creator token account, SPL interface]. The fee destination is the fee recipient's wallet for SOL and its USDC token account for USDC.

claim

Verifies a claim proof for one scope, creates the claim receipt for its scope nullifier, and pays the drop’s share or counts the vote.

Signed by: The relayer. Discriminator 3ec6d6c1d59f6cd2.

Arguments

NameTypeDescription
nrequired[u8; 32]The scope nullifier n = Poseidon(s, scope_id).
rootrequired[u8; 32]The person-tree root the proof was made against. Must be one of the last 64.
bindingrequired[u8; 32]For a drop, the owner hash of the claimant’s payout note; for a poll, the option index as a field element.
proofrequiredProofThe Groth16 proof of the claim circuit.
rings_datarequiredVec<u8>For a drop, the SPP transact data spending the pool note; empty for a poll.

Accounts

NameTypeDescription
relayersigner · writableThe relayer. Pays the fee and the receipt’s rent, and receives the relay fee.
configPDA ["config"]The config account.
scopewritableThe scope account.
treePDA ["tree"]The person tree, read for its root history.
receiptwritable · PDA ["claim", scope, n]The claim receipt at ["claim", scope, n].
pool_authorityreadThe pool authority PDA, which signs the pool spend.
system_program11111111111111111111111111111111The System Program.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits Claimed. Can fail with AlreadyClaimed, BadPoolNote, Closed, InsufficientRelayBudget, InvalidField, NotOpen, ProofInvalid, RootUnknown, ScopeFull, WrongBinding.

For a drop, the remaining accounts are SPP's transact accounts, [payer, tree, SPP, system program, tree, nullifier PDA, pool authority], followed by the relay-fee withdrawal group: for SOL [SOL interface, relayer], for USDC [SPP CPI authority, mint, SPL interface, relayer token account, token program]. A drop with a zero relay fee has no withdrawal group.

close_scope

Settles a scope after its window: a drop’s remaining pool goes back to the creator, a poll’s unspent relay budget too. Anyone can call it.

Signed by: Anyone. Discriminator 055522b3d7b0cad3.

Arguments

NameTypeDescription
rings_datarequiredVec<u8>For a drop with funds left, the SPP transact data withdrawing the pool to the creator; otherwise empty.

Accounts

NameTypeDescription
payersigner · writableWhoever closes the scope. Pays the transaction fee.
configPDA ["config"]The config account.
scopewritableThe scope account.
creatorwritableThe scope’s creator, who receives what is left.
pool_authorityreadThe pool authority PDA, which signs the pool spend.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits ScopeClosed. Can fail with BadPoolNote, Closed, ScopeStillOpen.

close_claims

Closes claim receipts of a closed scope and returns each one’s rent to the relayer that paid it. Takes pairs of receipt and payer as remaining accounts.

Signed by: Anyone. Discriminator 76c1e41b6c9cbb6a.

Accounts

NameTypeDescription
scopereadThe closed scope whose receipts are closed.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits ClaimsClosed. Can fail with InvalidReceipt, ScopeStillOpen.

The remaining accounts are pairs of a claim receipt and the relayer recorded as its payer, both writable.

withdraw

Forwards an SPP transaction spending the claimant’s payout notes, signed as the holders authority, so a private balance can be paid out to a public address.

Signed by: The relayer. Discriminator b712469c946da122.

Arguments

NameTypeDescription
rings_datarequiredVec<u8>The SPP transact data, proved on the claimant’s device.

Accounts

NameTypeDescription
relayersigner · writableThe relayer. Pays the fee and receives the relay fee.
configPDA ["config"]The config account.
holders_authorityreadThe holders authority PDA at ["holders"], co-owner of every payout note.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits Withdrawn. Can fail with BadPoolNote.

The remaining accounts are SPP's transact accounts for the proven transaction. The holders authority must appear once among its signers; SPP checks the claimant's payout key for each note spent.

initialize

Creates the config, the OPRF registry and the empty person tree. Signed by the program’s upgrade authority, which becomes the admin.

Signed by: The upgrade authority. Discriminator afaf6d1f0d989bed.

Arguments

NameTypeDescription
settingsrequiredSettingsThe fee recipient, the relay fee per asset, the USDC mint and the Rings accounts. See Settings.

Accounts

NameTypeDescription
adminsigner · writableThe program’s upgrade authority. It pays the rent and is stored as the admin.
program_dataPDA [[32 bytes]]The program’s data account, read to check the upgrade authority.
configwritable · PDA ["config"]The config account, created here.
oprfwritable · PDA ["oprf"]The OPRF registry, created empty here.
treewritable · PDA ["tree"]The person tree, created and initialized with its empty-subtree hashes here.
system_program11111111111111111111111111111111The System Program.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits Initialized. Can fail with Unauthorized.

update_fees

Sets the fee recipient and the relay fee for each asset. Scopes already open keep the relay fee they were created with.

Signed by: The admin. Discriminator e11b0d064554acbf.

Arguments

NameTypeDescription
recipientrequiredPubkeyThe wallet that receives the protocol fee on drops.
solrequiredu64The relay fee for SOL scopes, in lamports.
usdcrequiredu64The relay fee for USDC scopes, in base units.

Accounts

NameTypeDescription
adminsignerThe admin recorded in the config.
configwritable · PDA ["config"]The config account.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits FeesUpdated.

set_issuer

Adds an issuer key to the registry, or sets whether it is active. A retired key no longer enrolls anyone.

Signed by: The admin. Discriminator 7af0d17fb3a4afce.

Arguments

NameTypeDescription
keyrequiredCurvePointThe issuer’s BabyJubJub public key.
activerequiredboolWhether credentials from this key can enroll.

Accounts

NameTypeDescription
adminsigner · writableThe admin. Pays the rent of a new issuer account.
configPDA ["config"]The config account, read to check the admin.
issuerwritable · PDA ["issuer", key_x, key_y]The issuer account for this key, created on first use.
system_program11111111111111111111111111111111The System Program.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits IssuerUpdated.

set_oprf

Writes the three public key shares and the combined OPRF key, their digest and a new version. Once anyone has enrolled, the combined key must stay the same.

Signed by: The admin. Discriminator d5f9e21e85158b1f.

Arguments

NameTypeDescription
sharesrequired[CurvePoint; 3]The public points of the three key shares, in node order 1, 2, 3.
combinedrequiredCurvePointThe combined OPRF public key K.

Accounts

NameTypeDescription
adminsignerThe admin.
configPDA ["config"]The config account, read to check the admin.
oprfwritable · PDA ["oprf"]The OPRF registry.
treePDA ["tree"]The person tree, read to see whether anyone has enrolled.
event_authorityPDA ["__event_authority"]Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event.
programreadThe Once program, for the event self-call.

Emits OprfUpdated. Can fail with ArithmeticOverflow, InvalidField, StaleOprfKey.

Types

Terms

What create_scope takes.

NameTypeDescription
kindScopeKindDrop or poll.
titleString1 to 64 bytes of UTF-8.
assetAssetSOL or USDC for a drop; SOL for a poll.
amount_per_personu64For a drop, what each claim takes, more than the relay fee. Zero for a poll.
capu64The most claims, above zero.
opens_ati64When claims open, Unix seconds, zero or later.
closes_ati64When claims close, Unix seconds, after opens_at and after now.
optionsVec<String>For a poll, 2 to 8 labels of 1 to 32 bytes. Empty for a drop.
relay_budgetu64For a poll, the lamports deposited to pay relay fees. Zero for a drop.

Settings

What initialize takes.

NameTypeDescription
fee_recipientPubkeyThe wallet that receives the protocol fee.
sol_relay_feeu64The relay fee for SOL, in lamports.
usdc_relay_feeu64The relay fee for USDC, in base units.
usdc_mintPubkeyThe USDC mint.
spp_programPubkeyThe Solana Privacy Program.
registry_programPubkeyThe Rings user registry program.
state_treePubkeyThe Rings state tree.

Proof

A Groth16 proof over BN254 in the order the alt_bn128 syscalls take.

NameTypeDescription
a[u8; 64]The negated A point, G1, uncompressed.
b[u8; 128]The B point, G2, uncompressed, imaginary limbs first.
c[u8; 64]The C point, G1, uncompressed.

CurvePoint

A BabyJubJub point in affine coordinates.

NameTypeDescription
x[u8; 32]x, 32 bytes big-endian.
y[u8; 32]y, 32 bytes big-endian.

Asset

The asset a scope pays in.

NameTypeDescription
Solvariant 0SOL.
Usdcvariant 1USDC, the mint in the config.

ScopeKind

What a claim in the scope does.

NameTypeDescription
Dropvariant 0Pays a share.
Pollvariant 1Counts a vote.