> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentwallex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ウォレット操作

> ウォレットの作成、入金、支払いの送信、残高確認、エージェントステータスの管理。

## エージェントウォレットの作成

各エージェントは独自のMPCセキュアなウォレットを取得します。作成時にチェーンと初期ポリシーを指定します。

<CodeGroup>
  ```typescript TypeScript theme={null}
  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}`);
  ```

  ```python Python theme={null}
  agent = await aw.agents.create(
      name="payment-agent",
      chain="eip155:8453",
      policies={
          "max_transaction_amount": "500",
          "daily_limit": "5000",
          "allowed_tokens": ["USDC"],
      },
      metadata={"team": "growth"},
  )

  print(f"Agent ID: {agent.id}")
  print(f"Wallet address: {agent.wallet.address}")
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.agentwallex.com/api/v1/agents \
    -H "X-API-Key: awx_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "agent_name": "payment-agent",
      "chain": "eip155:8453",
      "metadata": "{\"team\":\"growth\"}"
    }'
  ```
</CodeGroup>

## ウォレットへの入金

エージェントのウォレットアドレスにトークンを送信します。ウォレットアドレスは、任意のソースからトークンを受信できる標準のオンチェーンアドレスです。

<Note>
  サンドボックスモード（`eip155:84532`）では、テストネットフォーセットを使用してテストトークンを取得します。実際の資金は不要です。
</Note>

x402操作の場合、残高エンドポイント経由で入金することもできます：

```bash theme={null}
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署名を通過します。

<CodeGroup>
  ```typescript TypeScript theme={null}
  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
  ```

  ```python Python theme={null}
  tx = await aw.payments.send(
      agent_id="agent_abc123",
      to="0xRecipientAddress",
      amount="50.00",
      token="USDC",
      memo="Payment for API access",
  )

  print(f"Hash: {tx.hash}")
  print(f"Status: {tx.status}")
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.agentwallex.com/api/v1/transactions \
    -H "X-API-Key: awx_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "agent_id": "agent_abc123",
      "direction": "outbound",
      "type": "transfer",
      "to_address": "0xRecipientAddress",
      "amount": "50.00",
      "token": "USDC",
      "chain": "eip155:8453",
      "memo": "Payment for API access"
    }'
  ```
</CodeGroup>

## 残高の確認

エージェントのx402残高を照会します：

```bash theme={null}
curl -X GET https://api.agentwallex.com/api/v1/x402/balances \
  -H "X-API-Key: awx_your_api_key"
```

## トランザクションの一覧表示

エージェントのトランザクション履歴を表示します：

<CodeGroup>
  ```typescript TypeScript theme={null}
  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})`);
  });
  ```

  ```bash cURL theme={null}
  curl -X GET "https://api.agentwallex.com/api/v1/transactions?agent_id=agent_abc123&status=confirmed&page_size=50" \
    -H "X-API-Key: awx_your_api_key"
  ```
</CodeGroup>

## 凍結と凍結解除

エージェントのすべてのトランザクションを即座に停止します。緊急時や計画メンテナンスに便利です。

### 凍結

<CodeGroup>
  ```typescript TypeScript theme={null}
  await aw.agents.freeze("agent_abc123");
  // All transactions are now blocked
  ```

  ```bash cURL theme={null}
  curl -X PUT https://api.agentwallex.com/api/v1/agents/agent_abc123/status \
    -H "X-API-Key: awx_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"status": "inactive"}'
  ```
</CodeGroup>

### 凍結解除

<CodeGroup>
  ```typescript TypeScript theme={null}
  // Subject to 10-minute cool-down after freeze
  await aw.agents.unfreeze("agent_abc123");
  ```

  ```bash cURL theme={null}
  curl -X PUT https://api.agentwallex.com/api/v1/agents/agent_abc123/status \
    -H "X-API-Key: awx_your_api_key" \
    -H "Content-Type: application/json" \
    -d '{"status": "active"}'
  ```
</CodeGroup>

<Warning>
  凍結後、凍結解除するまでに10分間の必須クールダウン期間があります。それより早く凍結解除しようとするとエラーが返されます。
</Warning>

## エージェントの削除

エージェントとそのウォレットを永久に削除します。この操作は取り消せません。

```bash theme={null}
curl -X DELETE https://api.agentwallex.com/api/v1/agents/agent_abc123 \
  -H "X-API-Key: awx_your_api_key"
```

<Warning>
  削除前にウォレット残高がゼロであることを確認してください。削除後に残った資金にはアクセスできなくなります。
</Warning>
