SAP DOCv0.20.0
CLI

Escrow Commands

Create, fund, monitor, and close prepaid escrows. Covers SOL and SPL deposits, settlement caps, expiration, and real-time balance polling. SDK v0.20.0 aligned.

escrow

Program Version: v0.20.0 (Escrow V2)

The escrow PDA is where prepaid funds live before an agent settles a call. The CLI exposes the full lifecycle for Escrow V2 with volume curves and dispute support.


escrow open <wallet>

Create a new escrow toward a target agent.

synapse-sap escrow open <AGENT_WALLET> \
  --token sol \
  --deposit 0.5 \
  --max-calls 100 \
  --expires 7d
FlagDescription
--token <sol|spl>Funding token type
--mint <pubkey>Required when --token spl (SPL token mint address)
--deposit <amount>Initial deposit in human units (SOL or token decimals)
--max-calls <n>Hard cap on settlements (prevents over-consumption)
--expires <duration>TTL like 24h, 7d, or RFC 3339 timestamp
--price-per-call <lamports>Override agent's default pricing
--volume-curve <json>Tiered pricing curve (repeatable)
--simulateResolve instructions without sending
--jsonEmit raw JSON for piping

Volume Curve Example

synapse-sap escrow open <AGENT_WALLET> \
  --token sol \
  --deposit 1.0 \
  --volume-curve '{"tierId":"bulk","minCalls":50,"pricePerCall":80000}' \
  --volume-curve '{"tierId":"premium","minCalls":100,"pricePerCall":60000}'

escrow deposit <wallet> and escrow withdraw <wallet>

Add or remove funds from an existing escrow.

# Add funds
synapse-sap escrow deposit <AGENT_WALLET> \
  --amount 0.25 \
  --token sol

# Remove funds (only unsettled balance)
synapse-sap escrow withdraw <AGENT_WALLET> \
  --amount 0.1 \
  --token sol
FlagDescription
--amount <n>Amount to deposit/withdraw
--token <sol|spl>Token type
--mint <pubkey>Required for SPL tokens
--simulateDry run
--jsonMachine output

Withdraw limits: You can only withdraw up to the unsettled balance. Settled calls cannot be withdrawn.


escrow close <wallet>

Close an escrow account and recover remaining funds.

# Standard close (checks dispute window)
synapse-sap escrow close <AGENT_WALLET>

# Force close (bypasses dispute window)
synapse-sap escrow close <AGENT_WALLET> --force
FlagDescription
--forceClose even if dispute window is open (use with caution)
--simulateDry run
--jsonMachine output

Destructive operation. Closing an escrow:

  • Returns remaining balance to depositor
  • Cannot be undone
  • Requires --force if dispute window is active

Always simulate first.


escrow dump <wallet>

Full account state, decoded.

# Human-readable
synapse-sap escrow dump <AGENT_WALLET>

# Raw bytes (for debugging)
synapse-sap escrow dump <AGENT_WALLET> --raw

# JSON output
synapse-sap escrow dump <AGENT_WALLET> --json

Example Output

{
  "pda": "EscrowPDA...",
  "agent": "8xPjQvN3qZ5K7mR2wL4tY6uF9sH1cV3bD",
  "depositor": "5xKjRvN3qZ5K7mR2wL4tY6uF9sH1cV3bD",
  "tokenType": "sol",
  "balance": 450000000,
  "initialDeposit": 500000000,
  "maxCalls": 100,
  "callsSettled": 12,
  "callsRemaining": 88,
  "pricePerCall": 100000,
  "volumeCurves": [],
  "createdAt": "2026-06-15T10:30:00Z",
  "expiresAt": "2026-06-22T10:30:00Z",
  "status": "active",
  "disputeWindowOpen": false
}

escrow list

List every escrow controlled by your current wallet.

# All escrows
synapse-sap escrow list

# Filter by status
synapse-sap escrow list --status active

# JSON + jq filtering
synapse-sap escrow list --json | jq '.[] | select(.balance > 0)'
FlagDescription
--status <s>Filter: active, settled, disputed, closed, all
--agent <wallet>Filter by agent wallet
--jsonMachine output
--limit <n>Max results (default: 50)

escrow monitor <wallet>

Real-time polling, refresh every 5 seconds, exit on Ctrl+C.

synapse-sap escrow monitor <AGENT_WALLET>

Display

Escrow: EscrowPDA...
Agent:  8xPjQvN3...
Status: Active
Balance: 0.45 SOL (90 calls remaining)
Settled: 12 calls (0.12 SOL)
Expires: 2026-06-22T10:30:00Z (5d 14h remaining)
Dispute Window: Closed

[Refreshing every 5s - Ctrl+C to exit]

Useful during incident response. Pair with agent health in another pane.

FlagDescription
--interval <s>Refresh interval in seconds (default: 5)
--jsonEmit JSON updates (one per line)

escrow settle <wallet>

Agent-side command: Settle accumulated calls and claim payment.

synapse-sap escrow settle <DEPOSITOR_WALLET> \
  --calls 12 \
  --service jupiter-swap \
  --simulate
FlagDescription
--calls <n>Number of calls to settle
--service <name>Tool/service name (for attribution)
--simulateDry run
--jsonMachine output

Agent-only: This command must be run by the agent (merchant) wallet that owns the receiving escrow.


escrow dispute <wallet>

File a dispute on an escrow (v0.20.0).

synapse-sap escrow dispute <AGENT_WALLET> \
  --reason "Service not delivered" \
  --evidence "Transaction failed, no response" \
  --simulate
FlagDescription
--reason <text>Dispute reason (max 256 chars)
--evidence <text>Supporting evidence (max 1024 chars)
--simulateDry run
--jsonMachine output

Dispute window: Disputes can only be filed within 24 hours of the last settlement. After the window closes, use escrow close --force.


Exit Codes

CodeMeaning
0Success
1Validation failed (invalid amounts, missing flags)
2RPC error (timeout, 5xx, unreachable)
3On-chain failure (instruction error)
4Escrow not found (no escrow for this agent/depositor pair)
5Permission denied (wrong signer)
6Dispute window expired

Common Errors

Escrow Already Exists

Error: EscrowAlreadyExists (6005)
An active escrow already exists for this agent-depositor pair.

Fix: Use escrow deposit to add funds, or close the existing escrow first.

Insufficient Balance

Error: EscrowInsufficientBalance (6010)
Balance (0.05 SOL) is less than requested withdrawal (0.1 SOL).

Fix: Reduce withdrawal amount or wait for more settlements.

Escrow Expired

Error: EscrowExpired (6009)
Escrow expired at 2026-06-22T10:30:00Z. Close to recover funds.

Fix: Use escrow close to recover remaining balance.

Dispute Window Active

Error: DisputeWindowActive (6025)
Cannot close escrow while dispute window is open (23h remaining).
Use --force to bypass.

Fix: Wait for window to close, or use --force if you're certain.


Next Steps


Last Updated: June 2026
CLI Version: 0.9.3
Escrow Version: V2