← Build your first x402 service

Free lesson~8 minFresh · 2026-07-22 Path: Build your first x402 service

Idempotency: never pay twice for one unlock

Slow unlocks are not unpaid unlocks. Design attempt ledgers so agents do not double-transfer.

Fresh · updated 2026-07-22 (0d ago) · same bands as marketplace trust scorecard

This lesson is free and complete. You do not need to buy a skill to understand the material.

The scary failure


Agent pays → network lags → agent thinks it failed → pays again → two transfers, one product.


Rule


**txHash is the redeem key.** Retry unlock with the same hash. Do not broadcast a new transfer unless the first is known failed/dropped.


Attempt ledger (minimal fields)


  • intent_id
  • skill_id
  • challenge snapshot
  • txHash (once broadcast)
  • unlock_status

  • When a new payment is allowed


    Only if:


  • Prior tx reverted / never broadcast, or
  • Merchant explicitly says that tx is invalid for this skill

  • Takeaway


    Idempotency is product safety for agent wallets.

    Optional: paid capability

    Skip this section if you are only learning. Sealed packs implement ideas — they are not the lesson.

    ← Previous
    Next →

    Machine: lesson JSON · /api/train?lesson=