Open app

Tabs and vouchers

How an agent pays a service by the call without a transaction per call.

A tab is an open account between one agent and one service, recorded on chain. A voucher is the agent's signed promise of the running total on that tab. The agent sends a voucher with every call, and the service serves as long as the voucher checks out. Opening and closing the tab are transactions; the calls in between carry the voucher in an HTTP header and never touch the chain.

  1. Hello402 + Ayo-Hello
  2. open_tabon chain, no amount
  3. Voucherssigned running total per call
  4. Settleone confidential transfer
  5. close_tabsettlement signature recorded
One tab, from the first call to the settlement.

Opening a tab

The first call an agent makes to a service has no voucher, so the service answers 402 Payment Required with an Ayo-Hello header. The hello names the service's on-chain account, its price per unit, the unit, the mint and the service's Ring address. The headers reference has every field.

The agent checks the hello against the service's record on chain, then sends open_tab. That instruction:

  • is signed by the agent's signing key, which also pays the transaction fee,
  • refuses a paused agent,
  • creates the Tab account at an address derived from the agent, the service and the agent's tab counter, so each tab address is used for one lifetime only,
  • charges the protocol's tab fee to the fee recipient.

No amount is written. The chain now shows that this agent opened a tab with this service.

Vouchers

Every call after the tab opens carries an Ayo-Voucher header with four values:

FieldTypeWhat it is
tabaddressThe tab this voucher belongs to
cumulativeAmountu64 stringEverything owed on the tab through this call, in the mint's base units
sequenceu64 string1 for the first call, then up by one each call
signaturebase58The agent's Ed25519 signature over the voucher message

The amount is cumulative: a voucher for sequence 5 with a total of 10,000 covers every call on the tab so far, including the four before it. The service keeps only the latest one.

The agent signs a 126-byte message: the ASCII prefix AYO_VOUCHER_V1, the Ayo program ID, the genesis hash of the cluster, the tab address, the cumulative amount and the sequence. Binding the program and the genesis hash means a voucher can't be replayed on another deployment or another cluster. The exact layout is in HTTP headers.

What the service checks

Before serving a call, the service's middleware checks that:

  1. the signature verifies against the agent's registered signing_key,
  2. the tab is open on chain and belongs to this agent and this service,
  3. the agent is active, not paused,
  4. the sequence is the next one expected,
  5. the total went up by exactly the price of this call,
  6. the total doesn't exceed the service's maximum unpaid amount per tab.

If any check fails, the call isn't served. Chain reads are cached per tab, so a service doesn't pay an RPC call per request.

Where the calls are recorded

Vouchers never go on chain. So that the owner can still watch every call, the agent's SDK posts each call to the Ayo API as an activity record encrypted to the agent's own viewing key. The service's middleware does the same on its side, encrypted to the service's viewing key. The API stores ciphertext and can't read either. The owner's browser derives the agent's viewing key and decrypts the feed. See Chain view and owner view.

How a tab ends

StatusReached byMeaning
openopen_tabCalls are being served against vouchers
settlingclose_tabThe agent made the settlement transfer and recorded its signature
settledconfirm_tabThe service decrypted the transfer and confirmed it
unpaidflag_unpaidThe window passed without payment; the last voucher is public
voidvoid_tabThe window passed and the service accepted no voucher on the tab

Settlement covers the first path, Unpaid proof the second.