Agent workflows
Record a completed payment
- Create a stable business reference before calling ProofRails.
- Submit only the deployed
TipRecordRequestfields. - Persist
receipt_id, transaction hash and reference atomically. - Poll the public receipt route until
anchoredorfailed. - Download and verify the current bundle.
- Store the verification result with the task log.
If the write response is lost, retry with the same chain, transaction hash and reference. ProofRails returns the existing receipt for those duplicate identities.
Buy an x402 resource
- Send an unsigned request to obtain the 402 challenge.
- Validate network, asset contract, amount, recipient, facilitator and deadline against policy.
- Require explicit value authorization.
- Sign once and retry the same request.
- Persist the authorization nonce before transmission.
- Parse
PAYMENT-RESPONSEand store its transaction andreceiptId. - If the HTTP response is lost, reconcile onchain state before doing anything else.
- Poll the receipt until
anchored.
The hosted x402 path uses real USD₮0 on Flare mainnet. Automatic repayment after a timeout is unsafe.
Data model for an agent run
At minimum, retain:
{
"task_id": "task-1842",
"business_reference": "order-1842",
"payment_transaction": "0x...",
"payment_nonce": "0x...",
"receipt_id": "<uuid>",
"resource_hash": "0x...",
"bundle_hash": "0x...",
"anchor_transaction": "0x...",
"verification_status": "anchored-and-matched"
}
Do not store private keys, API keys or raw reusable signatures in the task record.