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

# 入门指南

> 在 Polymarket 上做市的一次性设置

在开始做市之前,你需要完成这些一次性设置步骤——向 Polygon 充值 pUSD、部署钱包、授权代币交易并生成 API 凭证。

<Steps>
  <Step title="充值 pUSD">
    做市商需要在 Polygon 上有 pUSD 来为交易操作提供资金。

    | 方式            | 适用场景                | 文档                                        |
    | ------------- | ------------------- | ----------------------------------------- |
    | Bridge API    | 从其他链自动充值            | [Bridge 充值](/trading/bridge/deposit)      |
    | 直接 Polygon 转账 | 已经在 Polygon 上有 pUSD | N/A                                       |
    | 跨链桥           | 从 Ethereum 大额充值     | [支持的资产](/trading/bridge/supported-assets) |

    ### 使用 Bridge API

    ```typescript theme={null}
    // Get bridge addresses for your Polymarket wallet
    const deposit = await fetch("https://bridge.polymarket.com/deposit", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        address: "YOUR_POLYMARKET_WALLET_ADDRESS",
      }),
    });

    // Returns bridge addresses for EVM, SVM, and BTC networks
    const addresses = await deposit.json();
    // Send USDC to the appropriate address for your source chain
    ```
  </Step>

  <Step title="部署钱包">
    ### EOA - 外部拥有账户

    标准的 Ethereum 钱包。你需要为所有链上交易支付费用(授权、拆分、合并、交易执行)。

    ### Safe 钱包 - 推荐

    通过 Polymarket 的 relayer 部署的基于 Gnosis Safe 的钱包。优势:

    * **免 gas 交易** — Polymarket 为链上操作支付 gas 费用
    * **合约钱包** — 支持批量交易等高级功能

    使用 Relayer Client 部署 Safe 钱包:

    <CodeGroup>
      ```typescript TypeScript theme={null}
      import { RelayClient, RelayerTxType } from "@polymarket/builder-relayer-client";

      const client = new RelayClient({
        host: "https://relayer-v2.polymarket.com/",
        chain: 137,
        signer,
        relayerApiKey: process.env.RELAYER_API_KEY!,
        relayerApiKeyAddress: process.env.RELAYER_API_KEY_ADDRESS!,
        txType: RelayerTxType.SAFE,
      });

      // Deploy the Safe wallet
      const response = await client.deploy();
      const result = await response.wait();
      console.log("Safe Address:", result?.proxyAddress);
      ```

      ```python Python theme={null}
      from py_builder_relayer_client.client import RelayClient

      # client initialized with Relayer API Key 凭证 (参见免 Gas 交易)

      # Deploy the Safe wallet
      response = client.deploy()
      result = response.wait()
      print("Safe Address:", result.get("proxyAddress"))
      ```
    </CodeGroup>

    <Info>
      完整的 Relayer Client 设置(包括本地和远程签名配置)请参阅[免 Gas 交易](/trading/gasless)。
    </Info>
  </Step>

  <Step title="授权代币">
    交易前,你必须授权交易所合约使用你的代币。

    ### 所需授权

    | 代币         | 被授权方                  | 用途               |
    | ---------- | --------------------- | ---------------- |
    | pUSD       | CTF Contract          | 将 pUSD 拆分为结果代币   |
    | CTF (结果代币) | CTF Exchange          | 交易结果代币           |
    | CTF (结果代币) | Neg Risk CTF Exchange | 交易 neg-risk 市场代币 |

    ### 合约地址 - Polygon 主网

    ```typescript theme={null}
    const ADDRESSES = {
      pUSD: "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB",
      CTF: "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045",
      CTF_EXCHANGE: "0xE111180000d2663C0091e4f400237545B87B996B",
      NEG_RISK_CTF_EXCHANGE: "0xe2222d279d744050d28e00520010520000310F59",
      NEG_RISK_ADAPTER: "0xd91E80cF2E7be2e162c6513ceD06f1dD0dA35296",
    };
    ```

    ### 通过 Relayer Client 授权

    <CodeGroup>
      ```typescript TypeScript theme={null}
      import { ethers } from "ethers";
      import { Interface } from "ethers/lib/utils";

      const erc20Interface = new Interface([
        "function approve(address spender, uint256 amount) returns (bool)",
      ]);

      // Approve pUSD for CTF contract
      const approveTx = {
        to: ADDRESSES.pUSD,
        data: erc20Interface.encodeFunctionData("approve", [
          ADDRESSES.CTF,
          ethers.constants.MaxUint256,
        ]),
        value: "0",
      };

      const response = await client.execute([approveTx], "Approve pUSD for CTF");
      await response.wait();
      ```

      ```python Python theme={null}
      from web3 import Web3

      pUSD = "0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB"
      CTF = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045"
      MAX_UINT256 = 2**256 - 1

      approve_tx = {
          "to": pUSD,
          "data": Web3().eth.contract(
              address=pUSD,
              abi=[{
                  "name": "approve",
                  "type": "function",
                  "inputs": [
                      {"name": "spender", "type": "address"},
                      {"name": "amount", "type": "uint256"}
                  ],
                  "outputs": [{"type": "bool"}]
              }]
          ).encode_abi(abi_element_identifier="approve", args=[CTF, MAX_UINT256]),
          "value": "0"
      }

      response = client.execute([approve_tx], "Approve pUSD for CTF")
      response.wait()
      ```
    </CodeGroup>
  </Step>

  <Step title="生成 API 凭证">
    要下单和访问需要认证的端点,你需要从钱包派生 L2 API 凭证。

    <CodeGroup>
      ```typescript TypeScript theme={null}
      import { ClobClient } from "@polymarket/clob-client-v2";

      const client = new ClobClient({ host: "https://clob.polymarket.com", chain: 137, signer });

      // Derive API credentials from your wallet
      const credentials = await client.createOrDeriveApiKey();
      console.log("API Key:", credentials.key);
      console.log("Secret:", credentials.secret);
      console.log("Passphrase:", credentials.passphrase);
      ```

      ```python Python theme={null}
      from py_clob_client_v2 import ClobClient
      import os

      private_key = os.getenv("PRIVATE_KEY")

      temp_client = ClobClient("https://clob.polymarket.com", key=private_key, chain_id=137)
      credentials = temp_client.create_or_derive_api_key()
      ```
    </CodeGroup>

    获得凭证后,初始化客户端以进行需要认证的操作:

    <CodeGroup>
      ```typescript TypeScript theme={null}
      const tradingClient = new ClobClient({
        host: "https://clob.polymarket.com",
        chain: 137,
        signer: wallet,
        creds: credentials,
      });
      ```

      ```python Python theme={null}
      client = ClobClient(
          "https://clob.polymarket.com",
          key=private_key,
          chain_id=137,
          creds=credentials,
      )
      ```
    </CodeGroup>

    有关签名类型和 REST API 请求头的完整详情,请参阅[身份验证](/trading/overview#authentication)。
  </Step>
</Steps>

***

## 下一步

<CardGroup cols={2}>
  <Card title="交易" icon="chart-line" href="/market-makers/trading">
    发布限价单并管理报价
  </Card>

  <Card title="市场数据" icon="database" href="/market-data/overview">
    连接到实时市场数据
  </Card>
</CardGroup>
