Skip to content

Builder and Relayer Keys

Polygolem splits the V2 setup into three credential systems:

  • builder auto creates bootstrap CLOB L2 credentials at clob.polymarket.com/auth/api-key.
  • auth headless-onboard performs SIWE login and mints RELAYER_API_KEY + RELAYER_API_KEY_ADDRESS for deposit-wallet deploy and approval batches.
  • clob create-builder-fee-key creates the builder attribution value used in the V2 order builder bytes32 field.

Pipeline

Terminal window
# Step 1: Generate a fresh EOA
openssl rand -hex 32 > key.txt
# Step 2: Create or derive CLOB L2 credentials
POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
polygolem builder auto
# Step 3: Mint a V2 relayer API key
POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
polygolem auth headless-onboard
# Step 4: Mint a builder fee key, then export its key as a bytes32 builder code
POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
polygolem clob create-builder-fee-key
export POLYMARKET_BUILDER_CODE="0x..."
# Step 5: Deploy deposit wallet + approve + fund
POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
RELAYER_API_KEY="..." \
RELAYER_API_KEY_ADDRESS="..." \
polygolem deposit-wallet onboard --fund-amount 10 --json
# Step 6: Mint or verify the deposit-wallet-owned CLOB key
# New users do this once in the browser. Existing users can reuse their key.
DEPOSIT_WALLET=$(POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
polygolem --json deposit-wallet derive | jq -r '.data.depositWallet')
# Then store the browser-minted CLOB key in your local env:
export POLYMARKET_API_KEY="..."
export POLYMARKET_API_SECRET="..."
export POLYMARKET_API_PASSPHRASE="..."
# Step 7: Sync balance and trade
POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
polygolem clob update-balance --asset-type collateral
POLYMARKET_PRIVATE_KEY="0x$(cat key.txt)" \
polygolem clob create-order --token <id> --side buy --price 0.5 --size 10 \
--builder-code "$POLYMARKET_BUILDER_CODE"

CLOB L2 Credentials

builder auto signs a ClobAuth EIP-712 typed data message locally and posts it to clob.polymarket.com/auth/api-key for bootstrap credentials:

POST https://clob.polymarket.com/auth/api-key
Headers:
POLY_ADDRESS = EOA address for bootstrap keys, deposit wallet for trading keys
POLY_TIMESTAMP = Unix seconds
POLY_NONCE = "0"
POLY_SIGNATURE = raw EOA ClobAuth signature for bootstrap keys;
ERC-7739 wrapped ClobAuth signature for deposit-wallet keys
EIP-712 typed data:
domain: { name: "ClobAuthDomain", version: "1", chainId: 137 }
type: ClobAuth(address address, string timestamp, uint256 nonce, string message)
message: "This message attests that I control the given wallet"

The bootstrap endpoint returns the CLOB L2 HMAC triple: { apiKey, secret, passphrase }. Live deposit-wallet trading needs a deposit-wallet-owned CLOB key for balances, orders, trades, and cancellations. For brand-new users, mint that key with one browser login at polymarket.com. After it exists, store it locally and reuse it for headless trading.

Idempotent

Re-running builder auto for the same EOA returns the same credentials. The endpoint is idempotent — one EOA, one set of keys. Use --force to re-fetch and overwrite the local env file.

Relayer Keys

Relayer writes use a different key. auth headless-onboard signs a SIWE message with the EOA, exchanges it for a Gamma session, and mints the V2 relayer key at relayer-v2.polymarket.com/relayer/api/auth.

deposit-wallet deploy, deposit-wallet approve, and deposit-wallet onboard prefer RELAYER_API_KEY + RELAYER_API_KEY_ADDRESS when present.

Cost to the User

ItemCost
Generate EOAFree
Bootstrap CLOB L2 credsFree
Deposit-wallet CLOB keyFree, but new users need one browser login
V2 relayer keyFree
Builder fee keyFree
Wallet deployFree (gas sponsored)
Approvals (6 contracts)Free (gas sponsored)
Fund wallet (one tx)~$0.01 POL

Total: ~$0.01 POL + whatever pUSD you want to trade. Gas-sponsored relayer steps remain free; the browser requirement is an authentication boundary, not an on-chain cost.

With Reown/WalletConnect (Flutter/Arenaton)

The same flow works through Reown in Flutter:

// Polydart SDK
final client = await Polydart.live(
reownProvider: walletConnectProvider,
eoaAddress: '0x...',
);
// CLOB L2 credentials created via ClobAuth
await client.builder.auto();
// Relayer key minted via SIWE + relayer auth
await client.auth.headlessOnboard();
// Deploy wallet via server proxy → relayer
await client.wallet.deploy();
// Fund (EOA signs via Reown/MetaMask)
await client.wallet.fund(amount: 10.0);
// Trade (POLY_1271 signed via Reown)
await client.orders.buy(tokenId: '...').atPrice(0.5).forSize(10).submit();

See Also