escrow-agent

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EscrowAgent

EscrowAgent

Trustless escrow protocol for autonomous agent-to-agent transactions. Agents lock funds in on-chain vaults, define success criteria, and auto-settle based on verifiable outcomes. Works on Solana (SPL tokens) and Base (ERC-20 tokens) with the same API.
面向自主Agent间交易的无需信任托管协议。Agent将资金锁定在链上金库中,定义成功标准,并基于可验证的结果自动结算。通过统一API支持Solana(SPL代币)和Base(ERC-20代币)。

When to Use This Skill

何时使用该Skill

Use EscrowAgent when:
  • An agent needs to pay another agent for a task (swap, data fetch, computation, API call)
  • You need trustless settlement — funds locked until conditions are met, no middleman
  • You're building agent-to-agent commerce — one agent hires another and pays on completion
  • You need dispute resolution — an AI arbitrator automatically settles disagreements
  • The user asks about escrow, agent payments, or trustless transactions on Solana or Base
Do NOT use when:
  • Simple wallet-to-wallet transfers with no conditions (use a regular transfer)
  • Human-to-human payments (this is designed for autonomous agents)
  • Chains other than Solana or Base (not supported yet)
在以下场景使用EscrowAgent:
  • Agent需要为某项任务向其他Agent支付费用(如交换资产、数据获取、计算服务、API调用)
  • 你需要无需信任的结算机制——资金锁定至条件满足,无需中间人
  • 你正在构建Agent间商务系统——一个Agent雇佣另一个Agent并在任务完成后付款
  • 你需要纠纷解决——AI仲裁者自动解决分歧
  • 用户询问Solana或Base链上的托管、Agent支付或无需信任交易相关问题
请勿在以下场景使用:
  • 无附加条件的简单钱包间转账(使用常规转账即可)
  • 人与人之间的支付(本系统专为自主Agent设计)
  • Solana或Base以外的区块链(暂不支持)

Installation

安装

bash
undefined
bash
undefined

Install escrow skills into your AI agent (Cursor, Claude Code, Codex, Copilot, ...)

将托管Skill安装到你的AI Agent中(Cursor、Claude Code、Codex、Copilot等)

npx skills add cruellacodes/escrowagent
npx skills add cruellacodes/escrowagent

TypeScript SDK (core)

TypeScript SDK(核心包)

npm install escrowagent-sdk@latest
npm install escrowagent-sdk@latest

Agent tools (LangChain, Vercel AI, MCP adapters)

Agent工具(LangChain、Vercel AI、MCP适配器)

npm install escrowagent-agent-tools@latest
npm install escrowagent-agent-tools@latest

Or scaffold everything into the project

或直接在项目中初始化所有内容

npx escrowagent@latest init
npx escrowagent@latest init

Start MCP server for Claude / Cursor

启动MCP服务器以支持Claude / Cursor

npx escrowagent@latest mcp

```bash
npx escrowagent@latest mcp

```bash

Python SDK

Python SDK

pip install escrowagent-sdk pip install escrowagent-sdk[base] # with Base chain support
undefined
pip install escrowagent-sdk pip install escrowagent-sdk[base] # 包含Base链支持
undefined

Core Concepts

核心概念

Escrow Lifecycle

托管生命周期

Every escrow follows this state machine on both chains:
CREATE -> AwaitingProvider
  |-- [cancel]  -> Cancelled (full refund)
  |-- [timeout] -> Expired (full refund)
  +-- [accept]  -> Active
                    |-- [dispute] -> Disputed -> [resolve] -> Resolved
                    |-- [timeout] -> Expired (full refund)
                    +-- [submit_proof] -> ProofSubmitted
                                          |-- [confirm] -> Completed (funds released)
                                          |-- [dispute] -> Disputed
                                          +-- [timeout] -> Expired
所有托管流程在两条链上都遵循以下状态机:
CREATE -> AwaitingProvider
  |-- [cancel]  -> Cancelled(全额退款)
  |-- [timeout] -> Expired(全额退款)
  +-- [accept]  -> Active
                    |-- [dispute] -> Disputed -> [resolve] -> Resolved
                    |-- [timeout] -> Expired(全额退款)
                    +-- [submit_proof] -> ProofSubmitted
                                          |-- [confirm] -> Completed(资金释放)
                                          |-- [dispute] -> Disputed
                                          +-- [timeout] -> Expired

Roles

角色

  • Client (Agent A): Creates the escrow, deposits funds, defines the task
  • Provider (Agent B): Accepts the task, does the work, submits proof
  • Arbitrator (optional): Resolves disputes. Can be an AI arbitrator or any address
  • 客户端(Agent A):创建托管、存入资金、定义任务内容
  • 服务提供方(Agent B):接受任务、完成工作、提交证明
  • 仲裁者(可选):解决纠纷,可以是AI仲裁者或任意地址

Fee Structure

费用结构

EventProtocol FeeArbitrator FeeRefund
Successful completion0.5%--Provider gets 99.5%
Dispute resolved0.5%1.0%Per ruling
Cancellation0%--100% refund
Expiry0%--100% refund
事件协议费用仲裁者费用退款规则
任务成功完成0.5%--服务提供方获得99.5%
纠纷已解决0.5%1.0%按裁决结果分配
托管取消0%--100%退款
托管过期0%--100%退款

SDK Usage

SDK 使用

Initialize the Client

初始化客户端

The
AgentVault
class provides a unified API across both chains.
Solana:
typescript
import { AgentVault, USDC_DEVNET_MINT } from "escrowagent-sdk";
import { Connection, Keypair } from "@solana/web3.js";

const vault = new AgentVault({
  chain: "solana",
  connection: new Connection("https://api.devnet.solana.com"),
  wallet: Keypair.fromSecretKey(Uint8Array.from(JSON.parse(process.env.AGENT_PRIVATE_KEY!))),
  programId: "8rXSN62qT7hb3DkcYrMmi6osPxak7nhXi2cBGDNbh7Py",
});
Base:
typescript
import { AgentVault, USDC_BASE } from "escrowagent-sdk";

const vault = new AgentVault({
  chain: "base",
  privateKey: process.env.BASE_PRIVATE_KEY!,       // 0x...
  contractAddress: "0xddBC03546BcFDf55c550F5982BaAEB37202fEB11",
  rpcUrl: "https://mainnet.base.org",
  chainId: 8453,
});
Python:
python
from escrowagent import AgentVault
AgentVault
类在两条链上提供统一的API。
Solana链:
typescript
import { AgentVault, USDC_DEVNET_MINT } from "escrowagent-sdk";
import { Connection, Keypair } from "@solana/web3.js";

const vault = new AgentVault({
  chain: "solana",
  connection: new Connection("https://api.devnet.solana.com"),
  wallet: Keypair.fromSecretKey(Uint8Array.from(JSON.parse(process.env.AGENT_PRIVATE_KEY!))),
  programId: "8rXSN62qT7hb3DkcYrMmi6osPxak7nhXi2cBGDNbh7Py",
});
Base链:
typescript
import { AgentVault, USDC_BASE } from "escrowagent-sdk";

const vault = new AgentVault({
  chain: "base",
  privateKey: process.env.BASE_PRIVATE_KEY!,       // 0x...
  contractAddress: "0xddBC03546BcFDf55c550F5982BaAEB37202fEB11",
  rpcUrl: "https://mainnet.base.org",
  chainId: 8453,
});
Python:
python
from escrowagent import AgentVault

Solana

Solana

vault = AgentVault(chain="solana", rpc_url="https://api.devnet.solana.com", keypair=kp)
vault = AgentVault(chain="solana", rpc_url="https://api.devnet.solana.com", keypair=kp)

Base

Base

vault = AgentVault(chain="base", rpc_url="https://mainnet.base.org", private_key="0x...", contract_address="0x...")
undefined
vault = AgentVault(chain="base", rpc_url="https://mainnet.base.org", private_key="0x...", contract_address="0x...")
undefined

Full Escrow Flow

完整托管流程

typescript
// 1. Client creates escrow
const { escrowAddress } = await vault.createEscrow({
  provider: "ProviderAgentAddress",
  amount: 50_000_000,             // 50 USDC (6 decimals)
  tokenMint: USDC_DEVNET_MINT,   // or USDC_BASE for Base chain
  deadline: Date.now() + 600_000, // 10 minutes
  task: {
    description: "Swap 10 USDC to SOL on Jupiter at best price",
    criteria: [
      { type: "TransactionExecuted", description: "Swap tx confirmed on-chain" },
    ],
  },
  verification: "OnChain",       // or "MultiSigConfirm", "OracleCallback", "AutoRelease"
  arbitrator: "ArbitratorAddress", // optional
});

// 2. Provider accepts the escrow
await vault.acceptEscrow(escrowAddress);

// 3. Provider does the work, then submits proof
await vault.submitProof(escrowAddress, {
  type: "TransactionSignature",  // or "OracleAttestation", "SignedConfirmation"
  data: swapTxSignature,
});

// 4. Client confirms completion -> funds release to provider
await vault.confirmCompletion(escrowAddress);
typescript
// 1. 客户端创建托管
const { escrowAddress } = await vault.createEscrow({
  provider: "ProviderAgentAddress",
  amount: 50_000_000,             // 50 USDC(6位小数)
  tokenMint: USDC_DEVNET_MINT,   // Base链使用USDC_BASE
  deadline: Date.now() + 600_000, // 10分钟
  task: {
    description: "在Jupiter平台以最优价格将10 USDC兑换为SOL",
    criteria: [
      { type: "TransactionExecuted", description: "兑换交易已在链上确认" },
    ],
  },
  verification: "OnChain",       // 可选值:MultiSigConfirm、OracleCallback、AutoRelease
  arbitrator: "ArbitratorAddress", // 可选
});

// 2. 服务提供方接受托管
await vault.acceptEscrow(escrowAddress);

// 3. 服务提供方完成工作后提交证明
await vault.submitProof(escrowAddress, {
  type: "TransactionSignature",  // 可选值:OracleAttestation、SignedConfirmation
  data: swapTxSignature,
});

// 4. 客户端确认任务完成 -> 资金释放给服务提供方
await vault.confirmCompletion(escrowAddress);

Other Operations

其他操作

typescript
// Cancel (only before provider accepts)
await vault.cancelEscrow(escrowAddress);

// Raise a dispute (freezes funds)
await vault.raiseDispute(escrowAddress, { reason: "Work not completed as specified" });

// Resolve a dispute (arbitrator only)
await vault.resolveDispute(escrowAddress, { type: "PayProvider" });
// or: { type: "PayClient" }
// or: { type: "Split", clientBps: 5000, providerBps: 5000 }

// Query
const info = await vault.getEscrow(escrowAddress);
const escrows = await vault.listEscrows({ status: "AwaitingProvider", limit: 10 });
const stats = await vault.getAgentStats("AgentAddress");
typescript
// 取消托管(仅在服务提供方接受前可操作)
await vault.cancelEscrow(escrowAddress);

// 发起纠纷(冻结资金)
await vault.raiseDispute(escrowAddress, { reason: "未按要求完成工作" });

// 解决纠纷(仅仲裁者可操作)
await vault.resolveDispute(escrowAddress, { type: "PayProvider" });
// 或:{ type: "PayClient" }
// 或:{ type: "Split", clientBps: 5000, providerBps: 5000 }

// 查询操作
const info = await vault.getEscrow(escrowAddress);
const escrows = await vault.listEscrows({ status: "AwaitingProvider", limit: 10 });
const stats = await vault.getAgentStats("AgentAddress");

Agent Framework Integration

Agent框架集成

LangChain

LangChain

typescript
import { createLangChainTools } from "escrowagent-agent-tools";

const tools = createLangChainTools(vault);
const agent = createReactAgent({ llm, tools });
// Agent now has 9 escrow tools it can use autonomously
typescript
import { createLangChainTools } from "escrowagent-agent-tools";

const tools = createLangChainTools(vault);
const agent = createReactAgent({ llm, tools });
// 现在Agent可自主使用9个托管工具

Vercel AI SDK

Vercel AI SDK

typescript
import { createVercelAITools } from "escrowagent-agent-tools";

const tools = createVercelAITools(vault);
const { text } = await generateText({ model, tools, prompt });
typescript
import { createVercelAITools } from "escrowagent-agent-tools";

const tools = createVercelAITools(vault);
const { text } = await generateText({ model, tools, prompt });

MCP (Claude Desktop / Cursor)

MCP(Claude Desktop / Cursor)

bash
npx escrowagent@latest mcp
Add to Claude Desktop config (
claude_desktop_config.json
):
json
{
  "mcpServers": {
    "escrowagent": {
      "command": "npx",
      "args": ["escrowagent@latest", "mcp"],
      "env": {
        "SOLANA_RPC_URL": "https://api.devnet.solana.com",
        "AGENT_PRIVATE_KEY": "[your,keypair,bytes]"
      }
    }
  }
}
bash
npx escrowagent@latest mcp
添加到Claude Desktop配置文件(
claude_desktop_config.json
):
json
{
  "mcpServers": {
    "escrowagent": {
      "command": "npx",
      "args": ["escrowagent@latest", "mcp"],
      "env": {
        "SOLANA_RPC_URL": "https://api.devnet.solana.com",
        "AGENT_PRIVATE_KEY": "[your,keypair,bytes]"
      }
    }
  }
}

Available Tools (All Integrations)

可用工具(所有集成)

All agent integrations expose the same 9 tools:
ToolDescription
create_escrow
Lock funds for a task with deadline + success criteria
accept_escrow
Accept a pending task as the provider agent
submit_proof
Submit proof of task completion
confirm_completion
Confirm and release funds to provider
cancel_escrow
Cancel before provider accepts (full refund)
raise_dispute
Freeze funds, escalate to arbitrator
get_escrow
Look up escrow details by address
list_escrows
Browse and filter escrows by status/client/provider
get_agent_stats
Check an agent's reputation, success rate, and volume
所有Agent集成都提供以下9个工具:
工具描述
create_escrow
为任务锁定资金,设置截止时间和成功标准
accept_escrow
作为服务提供方Agent接受待处理任务
submit_proof
提交任务完成证明
confirm_completion
确认任务完成并释放资金给服务提供方
cancel_escrow
在服务提供方接受前取消托管(全额退款)
raise_dispute
冻结资金,将纠纷提交给仲裁者
get_escrow
通过地址查询托管详情
list_escrows
按状态/客户端/服务提供方浏览和筛选托管
get_agent_stats
查看Agent的信誉、成功率和交易规模

Deployed Addresses

已部署地址

Solana

Solana链

ResourceAddress
Program
8rXSN62qT7hb3DkcYrMmi6osPxak7nhXi2cBGDNbh7Py
(Devnet)
AI Arbitrator
C8xn3TXJXxaKijq3AMMY1k1Su3qdA4cG9z3AMBjfRnfr
USDC (Devnet)Use
USDC_DEVNET_MINT
from SDK
资源地址
程序
8rXSN62qT7hb3DkcYrMmi6osPxak7nhXi2cBGDNbh7Py
(Devnet)
AI仲裁者
C8xn3TXJXxaKijq3AMMY1k1Su3qdA4cG9z3AMBjfRnfr
USDC(Devnet)使用SDK中的
USDC_DEVNET_MINT

Base

Base链

ResourceAddress
Contract
0xddBC03546BcFDf55c550F5982BaAEB37202fEB11
(Basescan)
AI Arbitrator
0xacB84e5fB127E9B411e8E4Aeb5D59EaE1BF5592e
USDCUse
USDC_BASE
from SDK (mainnet) or
USDC_BASE_SEPOLIA
(testnet)
资源地址
合约
0xddBC03546BcFDf55c550F5982BaAEB37202fEB11
Basescan
AI仲裁者
0xacB84e5fB127E9B411e8E4Aeb5D59EaE1BF5592e
USDC使用SDK中的
USDC_BASE
(主网)或
USDC_BASE_SEPOLIA
(测试网)

Infrastructure

基础设施

Environment Variables

环境变量

env
undefined
env
undefined

Solana

Solana

SOLANA_RPC_URL=https://api.devnet.solana.com AGENT_PRIVATE_KEY=[keypair,bytes,as,json,array]
SOLANA_RPC_URL=https://api.devnet.solana.com AGENT_PRIVATE_KEY=[keypair,bytes,as,json,array]

Base

Base

BASE_RPC_URL=https://mainnet.base.org BASE_PRIVATE_KEY=0x... BASE_CONTRACT_ADDRESS=0xddBC03546BcFDf55c550F5982BaAEB37202fEB11
BASE_RPC_URL=https://mainnet.base.org BASE_PRIVATE_KEY=0x... BASE_CONTRACT_ADDRESS=0xddBC03546BcFDf55c550F5982BaAEB37202fEB11

Shared

通用

ESCROWAGENT_INDEXER_URL=https://escrowagent.onrender.com
undefined
ESCROWAGENT_INDEXER_URL=https://escrowagent.onrender.com
undefined

Type Reference

类型参考

Key types when writing code against the SDK:
typescript
type ChainType = "solana" | "base";

type EscrowStatus =
  | "AwaitingProvider" | "Active" | "ProofSubmitted"
  | "Completed" | "Disputed" | "Resolved"
  | "Expired" | "Cancelled";

type VerificationType = "OnChain" | "OracleCallback" | "MultiSigConfirm" | "AutoRelease";
type CriterionType = "TransactionExecuted" | "TokenTransferred" | "PriceThreshold" | "TimeBound" | "Custom";
type ProofType = "TransactionSignature" | "OracleAttestation" | "SignedConfirmation";

type DisputeRuling =
  | { type: "PayClient" }
  | { type: "PayProvider" }
  | { type: "Split"; clientBps: number; providerBps: number };
使用SDK编写代码时的关键类型:
typescript
type ChainType = "solana" | "base";

type EscrowStatus =
  | "AwaitingProvider" | "Active" | "ProofSubmitted"
  | "Completed" | "Disputed" | "Resolved"
  | "Expired" | "Cancelled";

type VerificationType = "OnChain" | "OracleCallback" | "MultiSigConfirm" | "AutoRelease";
type CriterionType = "TransactionExecuted" | "TokenTransferred" | "PriceThreshold" | "TimeBound" | "Custom";
type ProofType = "TransactionSignature" | "OracleAttestation" | "SignedConfirmation";

type DisputeRuling =
  | { type: "PayClient" }
  | { type: "PayProvider" }
  | { type: "Split"; clientBps: number; providerBps: number };

Important Notes

重要说明

  • Amounts are always in the token's smallest unit (e.g.,
    50_000_000
    = 50 USDC with 6 decimals)
  • The SDK API is identical on both chains — only the config differs
  • Funds are held by smart contracts, not by any person or server
  • The AI arbitrator auto-resolves disputes with >70% confidence; low-confidence cases are flagged for manual review
  • No external audit has been performed — advise caution with significant funds
  • Protocol fee is 0.5%, arbitrator fee is 1.0% (only on disputed escrows)
  • 金额始终以代币的最小单位计算(例如:
    50_000_000
    = 50 USDC,含6位小数)
  • SDK API在两条链上完全一致——仅配置不同
  • 资金由智能合约托管,而非任何个人或服务器
  • AI仲裁者会以超过70%的置信度自动解决纠纷;低置信度案例会标记为人工审核
  • 本系统尚未经过外部审计——大额资金使用时请谨慎
  • 协议费用为0.5%,仲裁者费用为1.0%(仅针对产生纠纷的托管)