返回顶部
t

trust-escrow信任托管

Create and manage USDC escrows for agent-to-agent payments on Base Sepolia. 30% gas savings, batch operations, dispute resolution.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
1,450
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

trust-escrow

Trust Escrow V2

基于Base Sepolia网络、面向代理间USDC支付的生产级托管合约。

适用场景

  • - 代理雇佣(交付后付款)
  • 服务平台
  • 跨代理协作
  • 悬赏/任务系统
  • x402支付集成

快速开始

合约信息

  • - 合约地址: 0x6354869F9B79B2Ca0820E171dc489217fC22AD64
  • 网络: Base Sepolia(链ID:84532)
  • USDC: 0x036CbD53842c5426634e7929541eC2318f3dCF7e
  • RPC: https://sepolia.base.org

平台

  • - 网页应用: https://trust-escrow-web.vercel.app
  • 代理文档: https://trust-escrow-web.vercel.app/agent-info
  • 集成指南: https://trust-escrow-web.vercel.app/skill.md

核心功能

createEscrow(receiver, amount, deadline)

创建新的托管合约。返回托管ID。

typescript
// 使用 viem/wagmi
await writeContract({
address: 0x6354869F9B79B2Ca0820E171dc489217fC22AD64,
abi: ESCROW_ABI,
functionName: createEscrow,
args: [
0xRECEIVER_ADDRESS, // address 接收方
parseUnits(100, 6), // uint96 金额(USDC 6位小数)
Math.floor(Date.now()/1000) + 86400 // uint40 截止时间(24小时)
]
});

release(escrowId)

发送方提前释放付款(手动批准)。

typescript
await writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: release,
args: [BigInt(escrowId)]
});

autoRelease(escrowId)

截止时间过后1小时检查期内,任何人可调用。

typescript
// 首先检查是否就绪
const ready = await readContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: canAutoRelease,
args: [BigInt(escrowId)]
});

if (ready) {
await writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: autoRelease,
args: [BigInt(escrowId)]
});
}

cancel(escrowId)

发送方在前30分钟内取消。

typescript
await writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: cancel,
args: [BigInt(escrowId)]
});

dispute(escrowId)

任一方标记争议以进行仲裁。

typescript
await writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: dispute,
args: [BigInt(escrowId)]
});



批量操作(V2功能)

批量创建托管

相比单笔交易节省41% gas。

typescript
await writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: createEscrowBatch,
args: [
[addr1, addr2, addr3, addr4, addr5], // address[] 接收方列表
[100e6, 200e6, 150e6, 300e6, 250e6], // uint96[] 金额列表
[deadline1, deadline2, deadline3, deadline4, deadline5] // uint40[] 截止时间列表
]
});

批量释放托管

相比单笔交易节省35% gas。

typescript
await writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: releaseBatch,
args: [[id1, id2, id3, id4, id5]]
});



查询函数

getEscrow(escrowId)

获取托管详情。

typescript
const escrow = await readContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: getEscrow,
args: [BigInt(escrowId)]
});

// 返回:[sender, receiver, amount, createdAt, deadline, state]
// state: 0=活跃, 1=已释放, 2=争议中, 3=已退款, 4=已取消

canAutoRelease(escrowId)

检查是否可自动释放。

typescript
const ready = await readContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: canAutoRelease,
args: [BigInt(escrowId)]
});

// 返回:布尔值

getEscrowBatch(escrowIds[])

高效批量查询(gas优化)。

typescript
const result = await readContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: getEscrowBatch,
args: [[id1, id2, id3, id4, id5]]
});

// 返回:[states[], amounts[]]



完整工作流程示例

typescript
import { createPublicClient, createWalletClient, http } from viem;
import { baseSepolia } from viem/chains;
import { privateKeyToAccount } from viem/accounts;

const ESCROW_ADDRESS = 0x6354869F9B79B2Ca0820E171dc489217fC22AD64;
const USDC_ADDRESS = 0x036CbD53842c5426634e7929541eC2318f3dCF7e;

const account = privateKeyToAccount(0xYOURPRIVATEKEY);

const walletClient = createWalletClient({
account,
chain: baseSepolia,
transport: http()
});

const publicClient = createPublicClient({
chain: baseSepolia,
transport: http()
});

// 1. 授权USDC
const approveTx = await walletClient.writeContract({
address: USDC_ADDRESS,
abi: [{
name: approve,
type: function,
inputs: [
{ name: spender, type: address },
{ name: amount, type: uint256 }
],
outputs: [{ name: , type: bool }],
stateMutability: nonpayable
}],
functionName: approve,
args: [ESCROW_ADDRESS, parseUnits(100, 6)]
});

await publicClient.waitForTransactionReceipt({ hash: approveTx });

// 2. 创建托管
const createTx = await walletClient.writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: createEscrow,
args: [
0xRECEIVER_ADDRESS,
parseUnits(100, 6),
Math.floor(Date.now()/1000) + 86400
]
});

const receipt = await publicClient.waitForTransactionReceipt({ hash: createTx });
console.log(托管已创建:, receipt.transactionHash);

// 3. 稍后:释放付款
const releaseTx = await walletClient.writeContract({
address: ESCROW_ADDRESS,
abi: ESCROW_ABI,
functionName: release,
args: [escrowId]
});

await publicClient.waitForTransactionReceipt({ hash: releaseTx });
console.log(付款已释放!);



功能特性

  • - ⚡ 节省30% gas - 优化存储 + 自定义错误
  • 📦 批量操作 - 批量处理减少41% gas
  • ⚖️ 争议解决 - 仲裁员处理冲突
  • ⏱️ 取消窗口 - 30分钟内可取消
  • 🔍 检查期 - 自动释放前1小时
  • 🤖 自动化守护 - 无需许可的自动释放

Gas费用

操作Gas消耗1 gwei下的费用
单次创建~65k~0.000065 ETH
单次释放
~45k | ~0.000045 ETH | | 批量创建(5个) | ~250k | ~0.00025 ETH | | 批量释放(5个) | ~180k | ~0.00018 ETH |

安全性

  • - ✅ 所有函数均使用重入保护
  • ✅ 输入验证配合自定义错误
  • ✅ 状态机验证
  • ✅ 使用OpenZeppelin合约(已审计)
  • ✅ Solidity 0.8.20+(溢出

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 trust-escrow-1776363980 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 trust-escrow-1776363980 技能

通过命令行安装

skillhub install trust-escrow-1776363980

下载

⬇ 下载 trust-escrow v1.0.0(免费)

文件大小: 2.99 KB | 发布时间: 2026-4-17 14:22

v1.0.0 最新 2026-4-17 14:22
Initial release: Production-ready escrow for agent-to-agent USDC payments on Base Sepolia. 30% gas savings, batch operations, dispute resolution.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部