walt/tables/receipts

receipts

one receipt per ticket. it ties a payment to an answer.

definition

1  walt      to provider      ask the question
2  provider  to walt          402, with the payment requirements
3  walt      to provider      ask again, header PAYMENT-SIGNATURE
4  provider  to facilitator   POST /verify
5  provider  to facilitator   POST /settle
6  provider  to walt          200 with the answer, header PAYMENT-RESPONSE
7  walt      to program       settle_ticket(receipt_hash, thought_hash)

what it is

x402 uses the http status 402, payment required. walt asks a model endpoint a question with no payment attached. the endpoint answers 402 and states what it wants: the amount, the asset, the account to pay and the network.

walt signs a payment for exactly that amount from the ticket's budget and repeats the request with the signed payment in a header. the endpoint hands the payment to a facilitator, which checks it and settles it on solana. the facilitator's fee payer covers the network fee, so the ticket only ever spends usdc.

when the answer comes back it carries the settlement result. walt hashes the ticket address, the provider, the amount and the settlement signature into one receipt hash and writes it into the ticket beside the hash of the answer.

what a receipt hash covers

receipt_hash = sha256(
  ticket_address          32 bytes
  provider                32 bytes
  amount                   8 bytes, little endian
  settlement_signature    64 bytes
)

notes

a receipt cannot be reused. it contains the ticket address, and the ticket address contains the trade.

if the endpoint never answers after payment, the receipt still exists and the thought hash stays empty. the ticket is closed as void and its remainder is burned.

figure

one paid call, from question to commit.

columns

columntypemeaning
ticketpubkeythe ticket that paid
providerpubkeyaccount that was paid
assetpubkeymint of the asset paid, usdc
amountu64amount settled
networktextnetwork named in the requirements
settlement_signature[u8; 64]signature of the settlement
receipt_hash[u8; 32]hash written into the ticket
walt/tables/receipts: the proof that a thought was paid for.