エージェントウォレットの作成
各エージェントは独自のMPCセキュアなウォレットを取得します。作成時にチェーンと初期ポリシーを指定します。
const agent = await aw.agents.create({
name: "payment-agent",
chain: "eip155:8453", // Base mainnet
policies: {
maxTransactionAmount: "500",
dailyLimit: "5000",
allowedTokens: ["USDC"],
},
metadata: { team: "growth" },
});
console.log(`Agent ID: ${agent.id}`);
console.log(`Wallet address: ${agent.wallet.address}`);
console.log(`Chain: ${agent.wallet.chain}`);
ウォレットへの入金
エージェントのウォレットアドレスにトークンを送信します。ウォレットアドレスは、任意のソースからトークンを受信できる標準のオンチェーンアドレスです。
サンドボックスモード(eip155:84532)では、テストネットフォーセットを使用してテストトークンを取得します。実際の資金は不要です。
x402操作の場合、残高エンドポイント経由で入金することもできます:
curl -X POST https://api.agentwallex.com/api/v1/x402/balances/deposit-address \
-H "X-API-Key: awx_your_api_key" \
-H "Content-Type: application/json" \
-d '{"agent_id": "agent_abc123", "chain": "eip155:8453"}'
支払いの送信
エージェントを通じてオンチェーン決済を実行します。トランザクションはブロードキャスト前にポリシーエンジンとMPC署名を通過します。
const tx = await aw.payments.send({
agentId: "agent_abc123",
to: "0xRecipientAddress",
amount: "50.00",
token: "USDC",
memo: "Payment for API access",
});
console.log(`Transaction ID: ${tx.id}`);
console.log(`Hash: ${tx.hash}`);
console.log(`Status: ${tx.status}`); // "pending" -> "confirmed"
console.log(`Fee: ${tx.fee}`); // Network gas fee
残高の確認
エージェントのx402残高を照会します:
curl -X GET https://api.agentwallex.com/api/v1/x402/balances \
-H "X-API-Key: awx_your_api_key"
トランザクションの一覧表示
エージェントのトランザクション履歴を表示します:
const { transactions } = await aw.payments.list({
agentId: "agent_abc123",
limit: 50,
status: "confirmed",
});
transactions.forEach(tx => {
console.log(`${tx.amount} ${tx.token} -> ${tx.to} (${tx.status})`);
});
凍結と凍結解除
エージェントのすべてのトランザクションを即座に停止します。緊急時や計画メンテナンスに便利です。
await aw.agents.freeze("agent_abc123");
// All transactions are now blocked
凍結解除
// Subject to 10-minute cool-down after freeze
await aw.agents.unfreeze("agent_abc123");
凍結後、凍結解除するまでに10分間の必須クールダウン期間があります。それより早く凍結解除しようとするとエラーが返されます。
エージェントの削除
エージェントとそのウォレットを永久に削除します。この操作は取り消せません。
curl -X DELETE https://api.agentwallex.com/api/v1/agents/agent_abc123 \
-H "X-API-Key: awx_your_api_key"
削除前にウォレット残高がゼロであることを確認してください。削除後に残った資金にはアクセスできなくなります。