Skip to main content
The Agentic Wallet includes a production-ready Anchor program that implements a full-featured escrow system on Solana. This enables trustless payments, milestone-based releases, and dispute resolution.

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_KEY in .env)

Build the Program

1

Build escrow contract

This compiles the Anchor program and generates the IDL.
2

Deploy to devnet

This command:
  1. Syncs declare_id! in the Rust code with your deploy keypair
  2. Builds and deploys via Anchor
  3. Updates .env with ESCROW_PROGRAM_ID=<deployed_id>
3

Verify deployment

Expected response:

Escrow Operations

All escrow operations are accessible via intents through the escrow protocol adapter.

Create Escrow

Initialize a new escrow account with funds locked from the creator.
  • escrowNumericId: Unique numeric identifier for this escrow (used in PDA derivation)
  • counterparty: Recipient public key
  • creator: Creator public key (must match wallet)
  • arbiter: Third-party arbiter for disputes
  • feeRecipient: Address to receive protocol fees
  • amount: Lamports to lock in escrow
  • deadlineUnixSec: Unix timestamp deadline
  • terms: Human-readable terms (hashed on-chain)

Accept Escrow

The recipient accepts the escrow, moving it from Created to Active status.
Acceptance must occur before the deadline, or the escrow cannot transition to Active.

Release Escrow

The creator releases funds to the recipient after work is completed.
Fees are automatically deducted based on 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 the Active phase.

Resolve Dispute

The arbiter decides the winner and distributes funds accordingly.
  • creator: Full refund to creator
  • recipient: 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

The x402_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

Returns:
  • intentHash: Hash of the original intent
  • policyHash: Policy evaluation fingerprint
  • simulationHash: Pre-flight simulation result
  • proofHash: 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:
This ensures deterministic addresses and prevents collisions.

CLI Integration

For interactive escrow workflows:
Select Protocol Interaction → Escrow and follow the prompts for:
  • Creating escrows
  • Accepting tasks
  • Releasing payments
  • Handling disputes

Security Considerations

Production Checklist:
  • Deploy program with a dedicated upgrade authority
  • Use hardware wallets for arbiter keys
  • Set reasonable fee caps (max 1000 basis points = 10%)
  • Validate all public keys before submission
  • Monitor program logs for anomalies

Fee Safety

The program enforces:
This caps fees at 10%.

Deadline Validation

Prevents creating escrows with past deadlines.

Next Steps

Multi-Agent Orchestration

Coordinate escrow operations across multiple agents

Gasless Transactions

Enable gasless escrow operations via Kora RPC