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
| Name | Type | Description |
|---|---|---|
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_untilrequired | u64 | The credential’s valid-until time, Unix seconds. Must be in the future. |
key_versionrequired | u64 | The OPRF registry version the proof was made against. Must equal the current version. |
proofrequired | Proof | The Groth16 proof of the enroll circuit. |
Accounts
| Name | Type | Description |
|---|---|---|
wallet | signer · writable | The enrolling wallet. It pays the rent and the fee, and is the only wallet that can revoke. |
person | writable · PDA ["person", n] | The person account at ["person", n]. |
issuer | read | The issuer account of the credential’s issuer. Absent or retired gives UnknownIssuer. |
oprf | PDA ["oprf"] | The OPRF registry. |
tree | writable · PDA ["tree"] | The person tree. |
system_program | 11111111111111111111111111111111 | The System Program. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
wallet | signer | The wallet recorded in the person account. |
person | writable · PDA ["person", n] | The person account at ["person", n]. |
tree | writable · PDA ["tree"] | The person tree. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
termsrequired | Terms | The scope’s terms. See Terms. |
rings_datarequired | Vec<u8> | Empty. The deposit is built inside the instruction. |
Accounts
| Name | Type | Description |
|---|---|---|
creator | signer · writable | The creator. Funds the scope and pays the rent. |
config | writable · PDA ["config"] | The config account. Its next scope ID becomes this scope’s ID. |
scope | writable · PDA ["scope", config_next_scope_id] | The new scope account at ["scope", id]. |
pool_authority | read | The pool authority PDA at ["pool"], the owner of the drop’s pool note. |
system_program | 11111111111111111111111111111111 | The System Program. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
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. |
proofrequired | Proof | The Groth16 proof of the claim circuit. |
rings_datarequired | Vec<u8> | For a drop, the SPP transact data spending the pool note; empty for a poll. |
Accounts
| Name | Type | Description |
|---|---|---|
relayer | signer · writable | The relayer. Pays the fee and the receipt’s rent, and receives the relay fee. |
config | PDA ["config"] | The config account. |
scope | writable | The scope account. |
tree | PDA ["tree"] | The person tree, read for its root history. |
receipt | writable · PDA ["claim", scope, n] | The claim receipt at ["claim", scope, n]. |
pool_authority | read | The pool authority PDA, which signs the pool spend. |
system_program | 11111111111111111111111111111111 | The System Program. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
rings_datarequired | Vec<u8> | For a drop with funds left, the SPP transact data withdrawing the pool to the creator; otherwise empty. |
Accounts
| Name | Type | Description |
|---|---|---|
payer | signer · writable | Whoever closes the scope. Pays the transaction fee. |
config | PDA ["config"] | The config account. |
scope | writable | The scope account. |
creator | writable | The scope’s creator, who receives what is left. |
pool_authority | read | The pool authority PDA, which signs the pool spend. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
scope | read | The closed scope whose receipts are closed. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
rings_datarequired | Vec<u8> | The SPP transact data, proved on the claimant’s device. |
Accounts
| Name | Type | Description |
|---|---|---|
relayer | signer · writable | The relayer. Pays the fee and receives the relay fee. |
config | PDA ["config"] | The config account. |
holders_authority | read | The holders authority PDA at ["holders"], co-owner of every payout note. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
settingsrequired | Settings | The fee recipient, the relay fee per asset, the USDC mint and the Rings accounts. See Settings. |
Accounts
| Name | Type | Description |
|---|---|---|
admin | signer · writable | The program’s upgrade authority. It pays the rent and is stored as the admin. |
program_data | PDA [[32 bytes]] | The program’s data account, read to check the upgrade authority. |
config | writable · PDA ["config"] | The config account, created here. |
oprf | writable · PDA ["oprf"] | The OPRF registry, created empty here. |
tree | writable · PDA ["tree"] | The person tree, created and initialized with its empty-subtree hashes here. |
system_program | 11111111111111111111111111111111 | The System Program. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
recipientrequired | Pubkey | The wallet that receives the protocol fee on drops. |
solrequired | u64 | The relay fee for SOL scopes, in lamports. |
usdcrequired | u64 | The relay fee for USDC scopes, in base units. |
Accounts
| Name | Type | Description |
|---|---|---|
admin | signer | The admin recorded in the config. |
config | writable · PDA ["config"] | The config account. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
keyrequired | CurvePoint | The issuer’s BabyJubJub public key. |
activerequired | bool | Whether credentials from this key can enroll. |
Accounts
| Name | Type | Description |
|---|---|---|
admin | signer · writable | The admin. Pays the rent of a new issuer account. |
config | PDA ["config"] | The config account, read to check the admin. |
issuer | writable · PDA ["issuer", key_x, key_y] | The issuer account for this key, created on first use. |
system_program | 11111111111111111111111111111111 | The System Program. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The 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
| Name | Type | Description |
|---|---|---|
sharesrequired | [CurvePoint; 3] | The public points of the three key shares, in node order 1, 2, 3. |
combinedrequired | CurvePoint | The combined OPRF public key K. |
Accounts
| Name | Type | Description |
|---|---|---|
admin | signer | The admin. |
config | PDA ["config"] | The config account, read to check the admin. |
oprf | writable · PDA ["oprf"] | The OPRF registry. |
tree | PDA ["tree"] | The person tree, read to see whether anyone has enrolled. |
event_authority | PDA ["__event_authority"] | Anchor’s event authority PDA at ["__event_authority"], which signs the self-call that carries the event. |
program | read | The Once program, for the event self-call. |
Emits OprfUpdated. Can fail with ArithmeticOverflow, InvalidField, StaleOprfKey.
Types
Terms
What create_scope takes.
| Name | Type | Description |
|---|---|---|
kind | ScopeKind | Drop or poll. |
title | String | 1 to 64 bytes of UTF-8. |
asset | Asset | SOL or USDC for a drop; SOL for a poll. |
amount_per_person | u64 | For a drop, what each claim takes, more than the relay fee. Zero for a poll. |
cap | u64 | The most claims, above zero. |
opens_at | i64 | When claims open, Unix seconds, zero or later. |
closes_at | i64 | When claims close, Unix seconds, after opens_at and after now. |
options | Vec<String> | For a poll, 2 to 8 labels of 1 to 32 bytes. Empty for a drop. |
relay_budget | u64 | For a poll, the lamports deposited to pay relay fees. Zero for a drop. |
Settings
What initialize takes.
| Name | Type | Description |
|---|---|---|
fee_recipient | Pubkey | The wallet that receives the protocol fee. |
sol_relay_fee | u64 | The relay fee for SOL, in lamports. |
usdc_relay_fee | u64 | The relay fee for USDC, in base units. |
usdc_mint | Pubkey | The USDC mint. |
spp_program | Pubkey | The Solana Privacy Program. |
registry_program | Pubkey | The Rings user registry program. |
state_tree | Pubkey | The Rings state tree. |
Proof
A Groth16 proof over BN254 in the order the alt_bn128 syscalls take.
| Name | Type | Description |
|---|---|---|
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.
| Name | Type | Description |
|---|---|---|
x | [u8; 32] | x, 32 bytes big-endian. |
y | [u8; 32] | y, 32 bytes big-endian. |
Asset
The asset a scope pays in.
| Name | Type | Description |
|---|---|---|
Sol | variant 0 | SOL. |
Usdc | variant 1 | USDC, the mint in the config. |
ScopeKind
What a claim in the scope does.
| Name | Type | Description |
|---|---|---|
Drop | variant 0 | Pays a share. |
Poll | variant 1 | Counts a vote. |