Skip to main content
Program ID: AhaDyVm8LBxpUwFdArA37LnHvNx6cNWe3KAiy8zGqhHF x0-escrow enables trustless conditional payments between agents and services. Funds are locked in a PDA-controlled token account until delivery conditions are met, a dispute is resolved, or a timeout expires.

State Machine

Every escrow follows a strict state transition graph:

Instructions

create_escrow

Creates a new escrow PDA and associated token vault.

fund_escrow

Buyer deposits the specified amount into the escrow vault. Transitions state from CreatedFunded.

mark_delivered

Seller claims delivery, optionally providing a proof hash. Transitions FundedDelivered.

release_funds

Buyer confirms satisfaction and releases funds to seller. Transitions DeliveredReleased. Also records a successful transaction to x0-reputation via CPI.

initiate_dispute

Either buyer or seller raises a dispute with evidence.
Transitions to Disputed. Records the dispute_initiated_slot for arbiter delay enforcement.

resolve_dispute

Only callable by the designated arbiter. Subject to ARBITER_RESOLUTION_DELAY_SLOTS = 216,000 (~24 hours) — the arbiter cannot resolve immediately after a dispute is raised.
  • true → Funds released to seller, state → Released
  • false → Funds refunded to buyer, state → Refunded

claim_auto_release

Seller claims funds after the timeout has expired. Only valid when state is Funded or Delivered and the timeout has passed.

claim_timeout_refund

Buyer claims a refund if the escrow has timed out without delivery and no auto-release was triggered.

cancel_escrow

Cancels the escrow before it is funded. Only the buyer can cancel. State → Cancelled.

State Account

EscrowAccount

PDA Seeds: ["escrow", buyer, seller, memo_hash]

Timeout Mechanics

  • Default timeout: 72 hours (DEFAULT_ESCROW_TIMEOUT_SECONDS = 259,200)
  • Minimum: 1 hour (MIN_ESCROW_TIMEOUT_SECONDS = 3,600)
  • Maximum: 30 days (MAX_ESCROW_TIMEOUT_SECONDS = 2,592,000)
  • Buffer: An additional ESCROW_TIMEOUT_BUFFER_SLOTS = 1,500 (~10 minutes) is added as safety margin
  • Auto-release: After timeout, the seller can call claim_auto_release to receive funds

Reputation Integration

On escrow completion, x0-escrow updates x0-reputation via CPI:

Events Emitted

Last modified on February 8, 2026