> ## 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.

# Operaciones de billetera

> Cree billeteras, fondéelas, envíe pagos, consulte saldos y gestione el estado de los agentes.

## Crear una billetera de agente

Cada agente obtiene su propia billetera con seguridad MPC. Especifique la cadena y las políticas iniciales al momento de la creación.

<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>

## Fondear la billetera

Envíe tokens a la dirección de billetera del agente. La dirección de billetera es una dirección on-chain estándar que puede recibir tokens de cualquier fuente.

<Note>
  En modo sandbox (`eip155:84532`), use un faucet de testnet para obtener tokens de prueba. No se necesitan fondos reales.
</Note>

Para operaciones x402, también puede depositar mediante el endpoint de saldos:

```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"}'
```

## Enviar un pago

Ejecute un pago on-chain a través del agente. La transacción pasa por el motor de políticas y la firma MPC antes de la difusión.

<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>

## Consultar saldo

Consulte el saldo x402 de un agente:

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

## Listar transacciones

Vea el historial de transacciones de un agente:

<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>

## Congelar y descongelar

Detenga instantáneamente todas las transacciones de un agente. Útil para emergencias o mantenimiento programado.

### Congelar

<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>

### Descongelar

<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>
  Hay un período obligatorio de enfriamiento de 10 minutos después de congelar antes de que pueda descongelar. Intentar descongelar antes devolverá un error.
</Warning>

## Eliminar un agente

Elimine permanentemente un agente y su billetera. Esta acción es irreversible.

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

<Warning>
  Asegúrese de que el saldo de la billetera sea cero antes de eliminar. Cualquier fondo restante será inaccesible después de la eliminación.
</Warning>
