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

# Polymarket

> Authenticate to Polymarket.

## MetaMask wallet

Put your credentials in `.env`.

```env theme={null}
POLYMARKET_PRIVATE_KEY=0x... # MetaMask EOA private key
POLYMARKET_FUNDER=0x... # Polymarket Safe address
```

(Find your Safe address at [polymarket.com/settings](https://polymarket.com/settings).)

Then pass them to the constructor:

<CodeGroup>
  ```python Python theme={null}
  import os
  from openpx import Exchange

  exchange = Exchange("polymarket", {
      "private_key": os.environ["POLYMARKET_PRIVATE_KEY"],
      "funder":      os.environ["POLYMARKET_FUNDER"],
  })
  ```

  ```javascript Node theme={null}
  import { Exchange } from "@openpx/sdk";

  const exchange = new Exchange("polymarket", {
      private_key: process.env.POLYMARKET_PRIVATE_KEY,
      funder:      process.env.POLYMARKET_FUNDER,
  });
  ```

  ```rust Rust theme={null}
  use openpx::ExchangeInner;
  use serde_json::json;

  let exchange = ExchangeInner::new("polymarket", json!({
      "private_key": std::env::var("POLYMARKET_PRIVATE_KEY").unwrap(),
      "funder": std::env::var("POLYMARKET_FUNDER").unwrap(),
  }))?;
  ```
</CodeGroup>

## Plain EOA (no Safe)

Drop `POLYMARKET_FUNDER` — that's it.

## If you get a Cloudflare WAF error

Polymarket blocks `POST /auth/api-key` from VPN / datacenter IPs.
Generate keys once at [polymarket.com/settings](https://polymarket.com/settings) → API Keys, then add:

```env theme={null}
POLYMARKET_API_KEY=...
POLYMARKET_API_SECRET=...
POLYMARKET_API_PASSPHRASE=...
```

Then pass them to the constructor:

<CodeGroup>
  ```python Python theme={null}
  import os
  from openpx import Exchange

  exchange = Exchange("polymarket", {
      "private_key":    os.environ["POLYMARKET_PRIVATE_KEY"],
      "funder":         os.environ["POLYMARKET_FUNDER"],
      "api_key":        os.environ["POLYMARKET_API_KEY"],
      "api_secret":     os.environ["POLYMARKET_API_SECRET"],
      "api_passphrase": os.environ["POLYMARKET_API_PASSPHRASE"],
  })
  ```

  ```javascript Node theme={null}
  import { Exchange } from "@openpx/sdk";

  const exchange = new Exchange("polymarket", {
      private_key:    process.env.POLYMARKET_PRIVATE_KEY,
      funder:         process.env.POLYMARKET_FUNDER,
      api_key:        process.env.POLYMARKET_API_KEY,
      api_secret:     process.env.POLYMARKET_API_SECRET,
      api_passphrase: process.env.POLYMARKET_API_PASSPHRASE,
  });
  ```

  ```rust Rust theme={null}
  use openpx::ExchangeInner;
  use serde_json::json;

  let exchange = ExchangeInner::new("polymarket", json!({
      "private_key": std::env::var("POLYMARKET_PRIVATE_KEY").unwrap(),
      "funder": std::env::var("POLYMARKET_FUNDER").unwrap(),
      "api_key": std::env::var("POLYMARKET_API_KEY").unwrap(),
      "api_secret": std::env::var("POLYMARKET_API_SECRET").unwrap(),
      "api_passphrase": std::env::var("POLYMARKET_API_PASSPHRASE").unwrap(),
  }))?;
  ```
</CodeGroup>
