Settlement
How a tab of any number of calls is paid with one confidential transfer.
A tab is paid once, at the end. The agent sends one confidential Ring transfer for the latest voucher's total to the service's Ring address, and the service confirms it by decrypting it. However many calls the tab carried, the chain records one transfer between two addresses, with no amount.
The steps
The agent decides to settle
The agent's SDK settles a tab when the service asks for settlement in a response header, when the tab has been idle, when its total reaches a threshold, or when a third of the service's settlement window is left.
One confidential transfer
The agent spends from its private balance to the service's Ring address, for exactly the cumulative amount of the last voucher. The transfer hides the asset, the amount and the memo. Each confidential transfer costs about 140,000 compute units.
close_tab
The agent sends
close_tabwith the signature of that transfer. The tab moves fromopentosettling, and itssettlement_signaturefield now points at the payment.The service decrypts and confirms
The service reads the transfer by its signature, decrypts the output addressed to it with its viewing key, and checks the amount against the last voucher it accepted. Then it sends
confirm_tab, signed by the service's signing key. The tab moves tosettledand the agent's and service's settled counters go up.
Why one transfer per tab
A confidential transfer carries a zero-knowledge proof, and proving costs time and compute. Vouchers move the per-call part off chain, where it costs a signature, and leave one proof for the whole tab, however many calls it carried.
A settled tab is paid once
The agent's SDK checks the tab's status on chain before it settles, so a restarted agent never pays a tab that is already settling or settled. The amount is the last voucher's cumulative total; see Vouchers.
What each side sees
| Who | Sees |
|---|---|
| The chain | close_tab and confirm_tab on this tab, and a confidential transfer from the agent's Ring address to the service's |
| The service | The amount it received, decrypted with its viewing key, matched to the tab |
| The owner | The amount, every call on the tab, and the settlement, decrypted with the agent's viewing key |
| Someone with a receipt link | This one settlement, decrypted with its per-transaction viewing key |