Use this page when you implement or debug the Algorand 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 HTTP 402, 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 JSON PaymentPayload:
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

With extra.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>):
  1. 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).
  2. Group size. paymentGroup is not empty (invalid_exact_avm_payload_empty_group), has at most 16 transactions (..._group_too_large), and paymentIndex is inside it (..._payment_index).
  3. Decode. Every transaction decodes from base64 msgpack (..._group_decode_failed).
  4. Group id. In a multi-transaction group, every transaction has the same group id (..._missing_group_id, ..._group_id_mismatch).
  5. Network. Every transaction’s genesis hash maps to the required network (..._genesis_hash_mismatch).
  6. Security, per transaction. No close_remainder_to or asset_close_to (..._close_to_detected); no blocked type, which is keyreg (..._blocked_transaction_type).
  7. 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).
  8. Payment terms. For ALGO the payment is a pay transaction, for an ASA an axfer of that asset (..._asset_id_mismatch); the receiver is payTo (..._recipient_mismatch); the amount equals the required amount exactly (..._amount_insufficient).
  9. 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).
  10. 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 type pay (..._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).
  11. 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_failed with the node’s message in invalid_message.
  12. Success. VerifyResponse(is_valid=True, payer=<buyer address>).
Codes shown as ..._ start with invalid_exact_avm_payload. All codes: Error codes.

Settlement

ExactAvmFacilitatorScheme.settle():
  1. Runs verify() again; on failure returns SettleResponse(success=False, error_reason=<code>).
  2. Signs the fee payer transaction, if the requirement names one.
  3. Submits the group with the signer’s send_group.
  4. Waits for confirmation with confirm_transaction (4 rounds by default).
  5. Returns SettleResponse(success=True, transaction=<txid>, network=<id>, payer=<buyer>), where transaction is the ID of paymentGroup[paymentIndex], the buyer’s payment (since 0.3.0; 0.2.x returned the fee payer transaction’s ID). A submission or confirmation error returns success=False with error_reason="transaction_failed".

Run it

Run a facilitator builds a payment with the client scheme and verifies and settles it with the facilitator scheme, without HTTP.