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

# 快速入门

> 在 5 分钟内集成 AgentWallex — 创建代理钱包并发送您的第一笔支付。

## 前置条件

* Node.js 18+ 或 Python 3.9+
* AgentWallex API 密钥（`awx_...`）— [注册抢先体验](https://agentwallex.com)
* 对区块链交易的基本了解

## 安装

<CodeGroup>
  ```bash npm theme={null}
  npm install @agentwallex/sdk
  ```

  ```bash yarn theme={null}
  yarn add @agentwallex/sdk
  ```

  ```bash pnpm theme={null}
  pnpm add @agentwallex/sdk
  ```

  ```bash pip theme={null}
  pip install agentwallex
  ```
</CodeGroup>

## 分步集成

<Steps>
  <Step title="初始化客户端">
    使用您的 API 密钥创建 AgentWallex 客户端。测试时使用 `sandbox`，主网使用 `production`。

    <CodeGroup>
      ```typescript TypeScript theme={null}
      import { AgentWallex } from "@agentwallex/sdk";

      const aw = new AgentWallex({
        apiKey: process.env.AGENTWALLEX_API_KEY!,
        environment: "sandbox", // use "production" for mainnet
      });
      ```

      ```python Python theme={null}
      from agentwallex import AgentWallex

      aw = AgentWallex(
          api_key=os.environ["AGENTWALLEX_API_KEY"],
          environment="sandbox",  # use "production" for mainnet
      )
      ```
    </CodeGroup>
  </Step>

  <Step title="创建代理钱包">
    每个代理都有自己的 MPC 安全钱包，并可配置策略。

    <CodeGroup>
      ```typescript TypeScript theme={null}
      const agent = await aw.agents.create({
        name: "my-trading-agent",
        chain: "eip155:84532",
        policies: {
          maxTransactionAmount: "100",   // USDC
          dailyLimit: "1000",
          allowedAddresses: ["0x..."],
        },
      });

      console.log(`Agent ID: ${agent.id}`);
      console.log(`Wallet: ${agent.wallet.address}`);
      ```

      ```python Python theme={null}
      agent = await aw.agents.create(
          name="my-trading-agent",
          chain="eip155:84532",
          policies={
              "max_transaction_amount": "100",
              "daily_limit": "1000",
              "allowed_addresses": ["0x..."],
          },
      )

      print(f"Agent ID: {agent.id}")
      print(f"Wallet: {agent.wallet.address}")
      ```
    </CodeGroup>
  </Step>

  <Step title="为钱包充值">
    向代理的钱包地址发送测试网代币。在 Base Sepolia 上，您可以使用[水龙头](https://www.coinbase.com/faucets/base-ethereum-goerli-faucet)获取测试 USDC。

    <Note>
      在沙盒模式下，您的代理钱包位于测试网上。不会涉及真实资金风险。
    </Note>
  </Step>

  <Step title="发送支付">
    通过代理执行链上支付。

    <CodeGroup>
      ```typescript TypeScript theme={null}
      const tx = await aw.payments.send({
        agentId: agent.id,
        to: "0xRecipientAddress",
        amount: "10.00",
        token: "USDC",
      });

      console.log(`Transaction hash: ${tx.hash}`);
      console.log(`Status: ${tx.status}`); // "confirmed"
      ```

      ```python Python theme={null}
      tx = await aw.payments.send(
          agent_id=agent.id,
          to="0xRecipientAddress",
          amount="10.00",
          token="USDC",
      )

      print(f"Transaction hash: {tx.hash}")
      print(f"Status: {tx.status}")  # "confirmed"
      ```
    </CodeGroup>
  </Step>
</Steps>

## 底层运作机制

1. **策略检查** — 策略引擎根据代理的规则（消费限额、地址白名单、频率控制）验证交易。
2. **MPC 签名** — 交易使用 2-of-3 阈值 MPC 签名。没有任何单一方持有完整密钥。
3. **广播** — 签名后的交易被提交到网络。
4. **确认** — AgentWallex 监控并确认交易，然后发送 Webhook 事件。

## 后续步骤

<CardGroup cols={2}>
  <Card title="TypeScript SDK" icon="js" href="/zh/sdks/typescript">
    包含所有方法和类型的完整 SDK 参考。
  </Card>

  <Card title="REST API" icon="code" href="/zh/api-reference/overview">
    用于自定义集成的 HTTP 端点。
  </Card>

  <Card title="x402 微支付" icon="credit-card" href="/zh/features/x402-micropayments">
    为您的代理启用按 API 调用付费功能。
  </Card>

  <Card title="策略引擎" icon="shield-check" href="/zh/features/policy-engine">
    配置消费控制和安全规则。
  </Card>
</CardGroup>
