快速开始
5 分钟内集成 AgentWallex
概述
AgentWallex 为 AI Agent 提供 MPC 安全钱包,使其无需暴露私钥即可在链上交易。本指南将引导你完成首个 Agent 钱包的设置。
前置条件
- Node.js 18+ 或 Python 3.9+
- AgentWallex API 密钥(
awx_...)(申请早期访问) - 基本的区块链交易知识
安装
安装 TypeScript SDK:
npm install @agentwallex/sdk或者 Python:
pip install agentwallex快速开始
1. 初始化客户端
import { AgentWallex } from "@agentwallex/sdk";
const aw = new AgentWallex({
apiKey: process.env.AGENTWALLEX_API_KEY!,
environment: "sandbox", // 生产环境使用 "production"
});2. 创建 Agent 钱包
const agent = await aw.agents.create({
name: "my-trading-agent",
chain: "eip155:84532",
policies: {
maxTransactionAmount: "100", // USDC
dailyLimit: "1000",
allowedAddresses: ["0x..."],
},
});
console.log(`Agent ID: ${agent.id}`);
console.log(`钱包地址: ${agent.wallet.address}`);3. 执行支付
const tx = await aw.payments.send({
agentId: agent.id,
to: "0xRecipientAddress",
amount: "10.00",
token: "USDC",
});
console.log(`交易哈希: ${tx.hash}`);
console.log(`状态: ${tx.status}`); // "confirmed"底层机制
- 策略检查 — 策略引擎根据 Agent 的规则验证交易
- MPC 签名 — 使用 2-of-3 门限 MPC 签名交易(任何一方都无法获取完整密钥)
- 广播 — 签名后的交易提交到网络
- 确认 — AgentWallex 监控并确认交易
下一步
- TypeScript SDK 参考 — 完整 API 文档
- REST API 参考 — HTTP 端点自定义集成
- x402 微支付集成 — 启用按 API 调用付费
- 安全架构 — MPC 签名如何保护你的 Agent
- 策略配置 — 精细化支出控制