Program
Every instruction, account and event of Ayo's Solana program.
Ayo's Anchor program holds the public registry: the configuration, agents, services and tabs. It stores no amounts except the one a service makes public with flag_unpaid. Money moves in Privacy Rings, never through this program.
The program ID on the local validator is 7qLG23v9m3rmTNvpsBeubAUfPiaguFk5EJwQsK8vrriD. The IDL is backend/program/target/idl/ayo.json.
Instructions
init_config
Creates the singleton Config with the fee recipient, the tab fee and the genesis hash of the cluster. Signed by the admin and the program's own key, once per deployment. The genesis hash is read from the cluster's RPC and fixed for the life of the configuration.
| Account | Signer | Writable | What it is |
|---|---|---|---|
admin | yes | yes | May change the configuration |
program_key | yes | The program's own keypair, so only the deployer initializes | |
config | yes | The config account | |
system_program | System program | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
fee_recipient | pubkey | Receives every tab fee |
tab_fee_lamports | u64 | Flat fee per open_tab, in lamports |
genesis_hash | [u8; 32] | The cluster's genesis hash, part of every voucher message |
set_config
Changes the fee recipient and the tab fee. Signed by the admin. The genesis hash stays as it was.
| Account | Signer | Writable | What it is |
|---|---|---|---|
admin | yes | May change the configuration | |
config | yes | The config account | |
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
fee_recipient | pubkey | Receives every tab fee |
tab_fee_lamports | u64 | Flat fee per open_tab, in lamports |
register_agent
Creates an Agent at ["agent", signing_key]. Signed by the owner, who pays the rent, and by the agent's signing key, which proves the owner holds it. Stores the derivation index, the name (up to 80 bytes) and the agent's Ring address (up to 1,024 bytes). The agent starts Active.
| Account | Signer | Writable | What it is |
|---|---|---|---|
owner | yes | yes | The wallet that registered it |
signing_key | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions | |
agent | yes | The agent account | |
system_program | System program | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
index | u32 | Derivation index under the owner |
name | string | Display name |
ring_address | string | Ring receiving address |
set_agent_status
Sets the agent Active or Paused. Signed by the agent's owner. A paused agent can't open tabs, and services refuse its vouchers; it can still close tabs it already has.
| Account | Signer | Writable | What it is |
|---|---|---|---|
owner | yes | The wallet that registered it | |
agent | yes | The agent account | |
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
status | AgentStatus | Current status |
register_service
Creates a Service at ["service", signing_key]. Signed by the owner, who pays the rent, and by the service's signing key, derived from the owner's seed and the service index. Stores the index and the terms, which are checked: name up to 80 bytes, an http:// or https:// endpoint up to 512 bytes, unit up to 48 bytes, a price above zero, a settlement window above zero, and a maximum unpaid amount at least the price.
| Account | Signer | Writable | What it is |
|---|---|---|---|
owner | yes | yes | The wallet that registered it |
signing_key | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions | |
service | yes | The service account | |
system_program | System program | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
index | u32 | Derivation index under the owner |
terms | ServiceTerms | The listing: name, endpoint and billing terms |
update_service
Replaces the service's terms. Signed by the owner. While any tab is outstanding (opened but not yet settled, flagged or voided), only the name and endpoint can change; the billing terms (price, unit, mint, Ring address, window, maximum unpaid) stay as they are until every tab has ended.
| Account | Signer | Writable | What it is |
|---|---|---|---|
owner | yes | The wallet that registered it | |
service | yes | The service account | |
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
terms | ServiceTerms | The listing: name, endpoint and billing terms |
open_tab
Creates a Tab at ["tab", agent, service, tabs_opened], using the agent's opened counter before this tab, and moves tab_fee_lamports from the signing key to the fee recipient. Signed by the agent's signing key, which also pays the rent and the transaction fee. Refused for a paused agent. The agent's and service's opened counters go up.
| Account | Signer | Writable | What it is |
|---|---|---|---|
signing_key | yes | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions |
config | The config account | ||
fee_recipient | yes | Receives every tab fee | |
agent | yes | The agent account | |
service | yes | The service account | |
tab | yes | The tab account | |
system_program | System program | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
close_tab
Records the 64-byte signature of the confidential settlement transfer and moves the tab from Open to Settling. Signed by the agent's signing key. Allowed while the agent is paused.
| Account | Signer | Writable | What it is |
|---|---|---|---|
signing_key | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions | |
agent | The agent account | ||
tab | yes | The tab account | |
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
settlement_signature | [u8; 64] | Signature of the settlement transfer |
confirm_tab
Moves the tab from Settling to Settled after the service has decrypted the settlement. Signed by the service's signing key, which pays the rent of a SettlementClaim at ["settlement", signing_key, SHA-256(settlement signature)]. The claim means one settlement transfer can confirm only one tab for that service. Sets closed_at; the settled counters go up.
| Account | Signer | Writable | What it is |
|---|---|---|---|
signing_key | yes | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions |
service | yes | The service account | |
agent | yes | The agent account | |
tab | yes | The tab account | |
settlement_claim | yes | The SettlementClaim this confirmation creates | |
system_program | System program | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
flag_unpaid
Marks an Open or Settling tab Unpaid once the clock is past opened_at + settlement_window_seconds. Signed by the service's signing key. Takes the last voucher's cumulative amount, sequence and signature, and requires an Ed25519 precompile instruction in the same transaction that verified that signature with the agent's signing_key over the voucher message. The amount must be above zero and at most the service's maximum unpaid per tab. Stores it in flagged_amount, sets closed_at, and raises the unpaid counters. See Unpaid proof.
| Account | Signer | Writable | What it is |
|---|---|---|---|
signing_key | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions | |
service | yes | The service account | |
agent | yes | The agent account | |
tab | yes | The tab account | |
config | The config account | ||
instructions | The instructions sysvar, read to find the Ed25519 instruction | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Arguments:
| Field | Type | What it is |
|---|---|---|
cumulative_amount | u64 | The voucher's cumulative amount |
sequence | u64 | The voucher's sequence |
signature | [u8; 64] | The voucher's 64-byte signature |
void_tab
Closes an Open tab as Void once the clock is past opened_at + settlement_window_seconds. Signed by the service's signing key. Vouchers live off chain, so this is the service attesting that it accepted none on the tab: an agent that opened a tab and never made a paid call. Sets closed_at. A voided tab no longer counts as outstanding for update_service.
| Account | Signer | Writable | What it is |
|---|---|---|---|
signing_key | yes | yes | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions |
service | yes | The service account | |
tab | yes | The tab account | |
system_program | System program | ||
event_authority | Anchor event authority, ["__event_authority"] | ||
program | This program, for emit_cpi! |
Accounts
Account data starts with Anchor's 8-byte discriminator, then the fields in this order, Borsh-encoded.
Agent
One per agent, at ["agent", signing_key].
| Field | Type | What it is |
|---|---|---|
owner | pubkey | The wallet that registered it |
signing_key | pubkey | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions |
index | u32 | Derivation index under the owner |
name | string | Display name |
ring_address | string | Ring receiving address |
status | AgentStatus | Current status |
counters | Counters | Tabs opened, settled and unpaid |
Config
One per deployment, at ["config"].
| Field | Type | What it is |
|---|---|---|
admin | pubkey | May change the configuration |
fee_recipient | pubkey | Receives every tab fee |
tab_fee_lamports | u64 | Flat fee per open_tab, in lamports |
genesis_hash | [u8; 32] | The cluster's genesis hash, part of every voucher message |
Service
One per listing, at ["service", signing_key].
| Field | Type | What it is |
|---|---|---|
owner | pubkey | The wallet that registered it |
signing_key | pubkey | The agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions |
index | u32 | Derivation index under the owner |
terms | ServiceTerms | The listing: name, endpoint and billing terms |
counters | Counters | Tabs opened, settled and unpaid |
SettlementClaim
One per confirmed settlement, at ["settlement", signing_key, SHA-256(signature)].
| Field | Type | What it is |
|---|---|---|
tab | pubkey | The tab account |
Tab
One per tab, at ["tab", agent, service, tabs_opened]. Stays after the tab ends.
| Field | Type | What it is |
|---|---|---|
agent | pubkey | The agent account |
service | pubkey | The service account |
opened_at | i64 | Unix time the tab opened |
closed_at | Option<i64> | Unix time it became settled or unpaid |
status | TabStatus | Current status |
settlement_signature | Option<[u8; 64]> | Signature of the settlement transfer |
flagged_amount | Option<u64> | Cumulative amount made public by flag_unpaid |
Types
AgentStatus
Active, Paused
Counters
| Field | Type | What it is |
|---|---|---|
tabs_opened | u64 | All tabs opened |
tabs_settled | u64 | All tabs settled |
tabs_unpaid | u64 | All tabs flagged unpaid |
ServiceTerms
| Field | Type | What it is |
|---|---|---|
name | string | Display name |
endpoint | string | The paid HTTP endpoint |
price_per_unit | u64 | Price of one unit in the mint's base units |
unit | string | What one unit is |
mint | pubkey | The mint the service is paid in |
ring_address | string | Ring receiving address |
settlement_window_seconds | u32 | Seconds after opening before a tab can be flagged |
max_unpaid_per_tab | u64 | Largest cumulative amount served before settlement |
TabStatus
Open, Settling, Settled, Unpaid, Void
Events
Every state change emits an event through emit_cpi!, so it appears as an inner instruction of the transaction rather than in the logs. The indexer decodes them to build the API's chain events.
AgentChanged
| Field | Type | What it is |
|---|---|---|
agent | pubkey | The agent account |
owner | pubkey | The wallet that registered it |
status | AgentStatus | Current status |
registered | bool | True when the account was created, false when changed |
ConfigChanged
| Field | Type | What it is |
|---|---|---|
config | pubkey | The config account |
initialized | bool | True on init_config |
ServiceChanged
| Field | Type | What it is |
|---|---|---|
service | pubkey | The service account |
owner | pubkey | The wallet that registered it |
registered | bool | True when the account was created, false when changed |
TabChanged
| Field | Type | What it is |
|---|---|---|
tab | pubkey | The tab account |
agent | pubkey | The agent account |
service | pubkey | The service account |
status | TabStatus | Current status |
opened_at | i64 | Unix time the tab opened |
closed_at | Option<i64> | Unix time it became settled or unpaid |
flagged_amount | Option<u64> | Cumulative amount made public by flag_unpaid |
Errors
Every program error, with its number, is listed in Errors.