exact scheme: the wire format, what the facilitator checks and in what order, and how settlement reports back. The scheme pays exactly the requested amount of one asset to one address, in an atomic group, so the payment and the fee sponsorship both happen or neither does. The official specification is scheme_exact_algo.md.
Wire format
PAYMENT-REQUIRED (server to client)
With HTTP402, the server sends a base64-encoded JSON PaymentRequired object (x402 version 2). Real captured headers, with every field explained, are on HTTP 402 response reference.
PAYMENT-SIGNATURE (client to server)
The client retries with a base64-encoded JSONPaymentPayload:
paymentGroup holds every transaction of the group in order: the buyer’s signed, the fee payer’s unsigned. paymentIndex points at the buyer’s payment.
Atomic group layout
Withextra.feePayer, paymentGroup is two transactions: the fee payer’s 0-amount self-payment with a fee of 2,000 microALGO (2 × the minimum fee) at index 0, signed by the facilitator at settlement, and the buyer’s pay or axfer of the amount with fee 0 at index 1. Without a fee payer it is one buyer payment that pays the network fee (1,000 microALGO minimum). Why, and the full table: How it works.
Verification steps
ExactAvmFacilitatorScheme.verify() runs these checks in order and stops at the first failure, returning VerifyResponse(is_valid=False, invalid_reason=<code>):
- Scheme and network. Both the accepted requirement and the server’s requirement use scheme
exact(unsupported_scheme); the accepted network equals the required one (network_mismatch). - Group size.
paymentGroupis not empty (invalid_exact_avm_payload_empty_group), has at most 16 transactions (..._group_too_large), andpaymentIndexis inside it (..._payment_index). - Decode. Every transaction decodes from base64 msgpack (
..._group_decode_failed). - Group id. In a multi-transaction group, every transaction has the same group id (
..._missing_group_id,..._group_id_mismatch). - Network. Every transaction’s genesis hash maps to the required network (
..._genesis_hash_mismatch). - Security, per transaction. No
close_remainder_toorasset_close_to(..._close_to_detected); no blocked type, which iskeyreg(..._blocked_transaction_type). - Rekeys, per group. A rekey is allowed only as a balanced pair in which the second rekey returns authority to the sender, within the group (
..._rekey_detected). - Payment terms. For ALGO the payment is a
paytransaction, for an ASA anaxferof that asset (..._asset_id_mismatch); the receiver ispayTo(..._recipient_mismatch); the amount equals the required amount exactly (..._amount_insufficient). - Buyer authorization. The payment is signed (
..._missing_signature) and its authorization verifies (..._invalid_signature): an Ed25519 signature by the sender or by its auth address (rekeyed account), a k-of-n multisig with at least the threshold of valid subsignatures, or a logic signature (the program itself is evaluated by the simulation). - Fee payer. The buyer is not one of the facilitator’s own addresses (
..._fee_payer_transferring_funds). If the requirement names a fee payer, the facilitator manages that address (fee_payer_not_managed_by_facilitator) and the group contains a transaction from it (..._missing_fee_payer). Every transaction sent by one of the facilitator’s addresses (not only the first) must be a self-payment of typepay(..._fee_payer_transaction_invalid) with amount 0 (..._fee_payer_has_amount), no close-to (..._fee_payer_has_close_to), no rekey (..._fee_payer_has_rekey_to) and a fee of at most 16,000 microALGO (..._fee_payer_transaction_invalid). - Simulation. The facilitator signs the fee payer transaction and simulates the group on algod with empty signatures allowed. A failure such as insufficient balance or a missing opt-in returns
transaction_simulation_failedwith the node’s message ininvalid_message. - Success.
VerifyResponse(is_valid=True, payer=<buyer address>).
..._ start with invalid_exact_avm_payload. All codes: Error codes.
Settlement
ExactAvmFacilitatorScheme.settle():
- Runs
verify()again; on failure returnsSettleResponse(success=False, error_reason=<code>). - Signs the fee payer transaction, if the requirement names one.
- Submits the group with the signer’s
send_group. - Waits for confirmation with
confirm_transaction(4 rounds by default). - Returns
SettleResponse(success=True, transaction=<txid>, network=<id>, payer=<buyer>), wheretransactionis the ID ofpaymentGroup[paymentIndex], the buyer’s payment (since 0.3.0; 0.2.x returned the fee payer transaction’s ID). A submission or confirmation error returnssuccess=Falsewitherror_reason="transaction_failed".