에이전트 지갑 생성
모든 에이전트는 자체 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"
삭제 전에 지갑 잔액이 0인지 확인하세요. 삭제 후 남은 자금은 접근할 수 없게 됩니다.