Open app

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.

AccountSignerWritableWhat it is
adminyesyesMay change the configuration
program_keyyesThe program's own keypair, so only the deployer initializes
configyesThe config account
system_programSystem program
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
fee_recipientpubkeyReceives every tab fee
tab_fee_lamportsu64Flat 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.

AccountSignerWritableWhat it is
adminyesMay change the configuration
configyesThe config account
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
fee_recipientpubkeyReceives every tab fee
tab_fee_lamportsu64Flat 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.

AccountSignerWritableWhat it is
owneryesyesThe wallet that registered it
signing_keyyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
agentyesThe agent account
system_programSystem program
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
indexu32Derivation index under the owner
namestringDisplay name
ring_addressstringRing 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.

AccountSignerWritableWhat it is
owneryesThe wallet that registered it
agentyesThe agent account
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
statusAgentStatusCurrent 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.

AccountSignerWritableWhat it is
owneryesyesThe wallet that registered it
signing_keyyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
serviceyesThe service account
system_programSystem program
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
indexu32Derivation index under the owner
termsServiceTermsThe 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.

AccountSignerWritableWhat it is
owneryesThe wallet that registered it
serviceyesThe service account
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
termsServiceTermsThe 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.

AccountSignerWritableWhat it is
signing_keyyesyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
configThe config account
fee_recipientyesReceives every tab fee
agentyesThe agent account
serviceyesThe service account
tabyesThe tab account
system_programSystem program
event_authorityAnchor event authority, ["__event_authority"]
programThis 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.

AccountSignerWritableWhat it is
signing_keyyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
agentThe agent account
tabyesThe tab account
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat 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.

AccountSignerWritableWhat it is
signing_keyyesyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
serviceyesThe service account
agentyesThe agent account
tabyesThe tab account
settlement_claimyesThe SettlementClaim this confirmation creates
system_programSystem program
event_authorityAnchor event authority, ["__event_authority"]
programThis 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.

AccountSignerWritableWhat it is
signing_keyyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
serviceyesThe service account
agentyesThe agent account
tabyesThe tab account
configThe config account
instructionsThe instructions sysvar, read to find the Ed25519 instruction
event_authorityAnchor event authority, ["__event_authority"]
programThis program, for emit_cpi!

Arguments:

FieldTypeWhat it is
cumulative_amountu64The voucher's cumulative amount
sequenceu64The 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.

AccountSignerWritableWhat it is
signing_keyyesyesThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
serviceyesThe service account
tabyesThe tab account
system_programSystem program
event_authorityAnchor event authority, ["__event_authority"]
programThis 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].

FieldTypeWhat it is
ownerpubkeyThe wallet that registered it
signing_keypubkeyThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
indexu32Derivation index under the owner
namestringDisplay name
ring_addressstringRing receiving address
statusAgentStatusCurrent status
countersCountersTabs opened, settled and unpaid

Config

One per deployment, at ["config"].

FieldTypeWhat it is
adminpubkeyMay change the configuration
fee_recipientpubkeyReceives every tab fee
tab_fee_lamportsu64Flat 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].

FieldTypeWhat it is
ownerpubkeyThe wallet that registered it
signing_keypubkeyThe agent's or service's Ed25519 key, derived from the owner's seed: signs and pays for its own transactions
indexu32Derivation index under the owner
termsServiceTermsThe listing: name, endpoint and billing terms
countersCountersTabs opened, settled and unpaid

SettlementClaim

One per confirmed settlement, at ["settlement", signing_key, SHA-256(signature)].

FieldTypeWhat it is
tabpubkeyThe tab account

Tab

One per tab, at ["tab", agent, service, tabs_opened]. Stays after the tab ends.

FieldTypeWhat it is
agentpubkeyThe agent account
servicepubkeyThe service account
opened_ati64Unix time the tab opened
closed_atOption<i64>Unix time it became settled or unpaid
statusTabStatusCurrent status
settlement_signatureOption<[u8; 64]>Signature of the settlement transfer
flagged_amountOption<u64>Cumulative amount made public by flag_unpaid

Types

AgentStatus

Active, Paused

Counters

FieldTypeWhat it is
tabs_openedu64All tabs opened
tabs_settledu64All tabs settled
tabs_unpaidu64All tabs flagged unpaid

ServiceTerms

FieldTypeWhat it is
namestringDisplay name
endpointstringThe paid HTTP endpoint
price_per_unitu64Price of one unit in the mint's base units
unitstringWhat one unit is
mintpubkeyThe mint the service is paid in
ring_addressstringRing receiving address
settlement_window_secondsu32Seconds after opening before a tab can be flagged
max_unpaid_per_tabu64Largest 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

FieldTypeWhat it is
agentpubkeyThe agent account
ownerpubkeyThe wallet that registered it
statusAgentStatusCurrent status
registeredboolTrue when the account was created, false when changed

ConfigChanged

FieldTypeWhat it is
configpubkeyThe config account
initializedboolTrue on init_config

ServiceChanged

FieldTypeWhat it is
servicepubkeyThe service account
ownerpubkeyThe wallet that registered it
registeredboolTrue when the account was created, false when changed

TabChanged

FieldTypeWhat it is
tabpubkeyThe tab account
agentpubkeyThe agent account
servicepubkeyThe service account
statusTabStatusCurrent status
opened_ati64Unix time the tab opened
closed_atOption<i64>Unix time it became settled or unpaid
flagged_amountOption<u64>Cumulative amount made public by flag_unpaid

Errors

Every program error, with its number, is listed in Errors.