Skip to main content
Polymarket’s Relayer Client enables gasless transactions for your users. Instead of requiring users to hold POL for gas, Polymarket’s infrastructure pays all transaction fees. This creates a seamless experience where users only need USDC.e to trade.

How It Works

The relayer acts as a transaction sponsor:
  1. Your app creates a transaction
  2. The user signs it with their private key
  3. Your app sends it to Polymarket’s relayer
  4. The relayer submits it onchain and pays the gas fee
  5. The transaction executes from the user’s wallet
Gasless transactions require Builder Program membership. You’ll need Builder API credentials to authenticate with the relayer.

What Is Covered

Polymarket pays gas for all operations routed through the relayer:
OperationDescription
Wallet deploymentDeploy Safe or Proxy wallets for new users
Token approvalsApprove contracts to spend USDC.e or outcome tokens
CTF operationsSplit, merge, and redeem positions
TransfersMove tokens between addresses

Prerequisites

Before using the relayer, you need:
RequirementSource
Builder API credentialsBuilder Profile
User’s private key or signerYour wallet integration
USDC.e balanceFor trading (not for gas)

Installation

npm install @polymarket/builder-relayer-client @polymarket/builder-signing-sdk

Client Setup

Initialize the relayer client with your signing configuration:
Use local signing when your backend handles all transactions securely.
import { createWalletClient, http, Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { polygon } from "viem/chains";
import { RelayClient } from "@polymarket/builder-relayer-client";
import { BuilderConfig } from "@polymarket/builder-signing-sdk";

const account = privateKeyToAccount(process.env.PRIVATE_KEY as Hex);
const wallet = createWalletClient({
  account,
  chain: polygon,
  transport: http(process.env.RPC_URL),
});

const builderConfig = new BuilderConfig({
  localBuilderCreds: {
    key: process.env.POLY_BUILDER_API_KEY!,
    secret: process.env.POLY_BUILDER_SECRET!,
    passphrase: process.env.POLY_BUILDER_PASSPHRASE!,
  },
});

const client = new RelayClient(
  "https://relayer-v2.polymarket.com/",
  137,
  wallet,
  builderConfig,
);
Never expose Builder API credentials in client-side code. Use environment variables or a secrets manager.

Relayer Authentication Headers

All requests to the relayer must include these authentication headers:
HeaderDescription
POLY_BUILDER_API_KEYYour Builder API key
POLY_BUILDER_TIMESTAMPUnix timestamp
POLY_BUILDER_PASSPHRASEYour Builder passphrase
POLY_BUILDER_SIGNATUREHMAC-SHA256 signature
The SDKs handle header generation automatically when you provide your credentials via BuilderConfig.

Wallet Types

Choose a wallet type when initializing the client:
TypeDeploymentBest For
SafeCall deploy() before first transactionMost builder integrations
ProxyAuto-deploys on first transactionMagic Link users
import { RelayClient, RelayerTxType } from "@polymarket/builder-relayer-client";

const client = new RelayClient(
  "https://relayer-v2.polymarket.com/",
  137,
  wallet,
  builderConfig,
  RelayerTxType.SAFE,
);

// Deploy before first transaction
const response = await client.deploy();
const result = await response.wait();
console.log("Safe Address:", result?.proxyAddress);

Executing Transactions

Use the execute method to send transactions through the relayer:
interface Transaction {
  to: string; // Target contract address
  data: string; // Encoded function call
  value: string; // POL to send (usually "0")
}

const response = await client.execute(transactions, "Description");
const result = await response.wait();

Token Approval

Approve contracts to spend tokens:
import { encodeFunctionData, maxUint256 } from "viem";

const USDC = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
const CTF = "0x4D97DCd97eC945f40cF65F87097ACe5EA0476045";

const approveTx = {
  to: USDC,
  data: encodeFunctionData({
    abi: [
      {
        name: "approve",
        type: "function",
        inputs: [
          { name: "spender", type: "address" },
          { name: "amount", type: "uint256" },
        ],
        outputs: [{ type: "bool" }],
      },
    ],
    functionName: "approve",
    args: [CTF, maxUint256],
  }),
  value: "0",
};

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

Redeem Positions

Exchange winning tokens for USDC.e after market resolution:
import { encodeFunctionData } from "viem";

const redeemTx = {
  to: CTF_ADDRESS,
  data: encodeFunctionData({
    abi: [
      {
        name: "redeemPositions",
        type: "function",
        inputs: [
          { name: "collateralToken", type: "address" },
          { name: "parentCollectionId", type: "bytes32" },
          { name: "conditionId", type: "bytes32" },
          { name: "indexSets", type: "uint256[]" },
        ],
        outputs: [],
      },
    ],
    functionName: "redeemPositions",
    args: [collateralToken, parentCollectionId, conditionId, indexSets],
  }),
  value: "0",
};

const response = await client.execute([redeemTx], "Redeem positions");
await response.wait();

Batch Transactions

Execute multiple operations atomically in a single call:
const approveTx = {
  to: USDC,
  data: encodeFunctionData({
    abi: erc20Abi,
    functionName: "approve",
    args: [CTF, maxUint256],
  }),
  value: "0",
};

const transferTx = {
  to: USDC,
  data: encodeFunctionData({
    abi: erc20Abi,
    functionName: "transfer",
    args: [recipientAddress, parseUnits("50", 6)],
  }),
  value: "0",
};

// Both execute atomically
const response = await client.execute(
  [approveTx, transferTx],
  "Approve and transfer",
);
await response.wait();
Batching reduces latency and ensures all transactions succeed or fail together.

Transaction States

Track transaction progress through these states:
StateTerminalDescription
STATE_NEWNoTransaction received by relayer
STATE_EXECUTEDNoSubmitted onchain
STATE_MINEDNoIncluded in a block
STATE_CONFIRMEDYesFinalized successfully
STATE_FAILEDYesFailed permanently
STATE_INVALIDYesRejected as invalid

Contract Addresses

See Contract Addresses for all Polymarket smart contract addresses on Polygon.

Resources

Next Steps