> ## 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>
  삭제 전에 지갑 잔액이 0인지 확인하세요. 삭제 후 남은 자금은 접근할 수 없게 됩니다.
</Warning>
