Overview
The escrow program is a real Anchor smart contract (not a memo placeholder) that supports:- Standard Escrow: Two-party escrow with arbiter support
- Milestone Escrow: Multi-phase payment releases
- x402 Protocol: HTTP 402 payment-required integration
- Dispute Resolution: Third-party arbiter workflow
- Auto-release: Time-based automatic releases
The program source code is in
programs/escrow/src/lib.rs and uses PDAs (Program Derived Addresses) for secure state management.Building and Deploying
Prerequisites
- Anchor CLI >= 0.31
- Solana CLI >= 1.18
- Funded devnet wallet (set via
PRIVATE_KEYin.env)
Build the Program
1
Build escrow contract
2
Deploy to devnet
- Syncs
declare_id!in the Rust code with your deploy keypair - Builds and deploys via Anchor
- Updates
.envwithESCROW_PROGRAM_ID=<deployed_id>
3
Verify deployment
Escrow Operations
All escrow operations are accessible via intents through theescrow protocol adapter.
Create Escrow
Initialize a new escrow account with funds locked from the creator.Intent Parameters
Intent Parameters
escrowNumericId: Unique numeric identifier for this escrow (used in PDA derivation)counterparty: Recipient public keycreator: Creator public key (must match wallet)arbiter: Third-party arbiter for disputesfeeRecipient: Address to receive protocol feesamount: Lamports to lock in escrowdeadlineUnixSec: Unix timestamp deadlineterms: Human-readable terms (hashed on-chain)
Accept Escrow
The recipient accepts the escrow, moving it fromCreated to Active status.
Release Escrow
The creator releases funds to the recipient after work is completed.fee_basis_points (e.g., 100 = 1%).
Refund Escrow
The creator can request a refund under specific conditions:- Before acceptance: Cancels the escrow (status →
Cancelled) - After deadline expiry: Refunds the creator (status →
Refunded)
Dispute Escrow
Either party can open a dispute during theActive phase.
Resolve Dispute
The arbiter decides the winner and distributes funds accordingly.Winner Options
Winner Options
creator: Full refund to creatorrecipient: Payout to recipient (minus fees)
Milestone Escrow
For multi-phase projects, use milestone escrows to release funds incrementally.Create Milestone Escrow
Release Individual Milestone
x402 Protocol Integration
Thex402_pay instruction enables HTTP 402 (Payment Required) workflows.
The
is_x402 flag in the on-chain state enables special handling for HTTP payment flows.Querying Escrow State
List Wallet Escrows
Check Transaction Proof
intentHash: Hash of the original intentpolicyHash: Policy evaluation fingerprintsimulationHash: Pre-flight simulation resultproofHash: Combined cryptographic proof- Transaction signature and explorer link
On-Chain Program Details
Account Structure
Status Lifecycle
1
Created
Initial state after
create_escrow. Funds locked, awaiting recipient acceptance.2
Active
Recipient has accepted. Creator can release, or either party can dispute.
3
Disputed
Dispute opened. Only arbiter can resolve.
4
Completed
Funds released to recipient. Escrow closed.
5
Refunded
Funds returned to creator after deadline. Escrow closed.
6
Cancelled
Creator cancelled before acceptance. Escrow closed.
7
Resolved
Arbiter resolved dispute. Escrow closed.
PDA Derivation
Escrow accounts use Program Derived Addresses:CLI Integration
For interactive escrow workflows:- Creating escrows
- Accepting tasks
- Releasing payments
- Handling disputes
Security Considerations
Fee Safety
The program enforces:Deadline Validation
Next Steps
Multi-Agent Orchestration
Coordinate escrow operations across multiple agents
Gasless Transactions
Enable gasless escrow operations via Kora RPC