Skip to main content

Overview

The Builder Signing Server is a self-hosted Express.js application that enables remote signing of builder authentication headers. By running this server, you can keep your Builder API credentials secure on your own infrastructure while still allowing your application to sign requests.
This server is designed to work with both the CLOB Client for order attribution and the Relayer Client for gasless transactions.

Why Use Remote Signing?

Remote signing provides enhanced security by:
  • Isolating credentials: Your Builder API keys never leave your secure server
  • Centralized key management: Manage credentials in one secure location
  • Reduced exposure: Client applications don’t need direct access to sensitive keys

Installation

Prerequisites

  • Node.js: v18 or higher
  • yarn or npm

Clone and Install

# Clone the repository
git clone https://github.com/Polymarket/builder-signing-server.git
cd builder-signing-server

# Install dependencies
yarn install

Configuration

Environment Variables

Create a .env file in the root directory with your Builder API credentials:
PORT=5001
POLY_BUILDER_API_KEY=your_builder_api_key
POLY_BUILDER_SECRET=your_builder_secret
POLY_BUILDER_PASSPHRASE=your_builder_passphrase
Security: Never commit your .env file to version control. Add it to .gitignore to prevent accidental exposure of your credentials.

Port Configuration

You can run the server on any port you choose. The default is 5001, but you can change this by setting the PORT environment variable. Make sure to configure your client applications to use the same port:
// In your client application
const builderConfig = new BuilderConfig({
    remoteBuilderConfig: {url: "http://localhost:3000/sign"}
});

Running the Server

Development Mode

For development with automatic reloading:
yarn start-dev

Production Mode

Build and run the compiled version:
# Start the production server
yarn start
The server will start and display:
Builder signing server listening on :5001

Client Integration

With CLOB Client

Configure the CLOB client to use your signing server for order attribution:
import { ClobClient } from "@polymarket/clob-client";
import { BuilderConfig } from "@polymarket/builder-signing-sdk";

const builderConfig = new BuilderConfig({
    remoteBuilderConfig: {url: "http://localhost:3000/sign"}
});

const clobClient = new ClobClient(
    host,
    chainId,
    wallet,
    creds,
    SignatureType.POLY_PROXY,
    funderAddress,
    undefined,
    false,
    builderConfig
);

// Orders will automatically use the signing server
const order = await clobClient.createOrder({
    price: 0.40,
    side: Side.BUY,
    size: 5,
    tokenID: "27072675915285915455116137912884489109876947142577610372904917850067886308458"
});

const response = await clobClient.postOrder(order);

With Relayer Client

Configure the relayer client to use your signing server for gasless transactions:
import { RelayClient } from "@polymarket/builder-relayer-client";
import { BuilderConfig } from "@polymarket/builder-signing-sdk";

const builderConfig = new BuilderConfig({
    remoteBuilderConfig: {url: "http://localhost:3000/sign"}
});

const relayClient = new RelayClient(
    relayerUrl,
    chainId,
    wallet,
    builderConfig
);

// Transactions will automatically use the signing server
const response = await relayClient.deploySafe();
const result = await response.wait();

Production Deployment

Troubleshooting

Server Won’t Start

Issue: Error: POLY_BUILDER_API_KEY environment variable is required Solution: Ensure your .env file contains all required variables:
  • POLY_BUILDER_API_KEY
  • POLY_BUILDER_SECRET
  • POLY_BUILDER_PASSPHRASE

Port Already in Use

Issue: Error: listen EADDRINUSE: address already in use :::5001 Solution: Change the port in your .env file:
PORT=5002
And update your client configuration accordingly.

Invalid Signature Errors

Issue: Client receives invalid signature errors Solution:
  1. Verify the request body is being passed correctly as a JSON string
  2. Check that the path and method match exactly what the client is sending
  3. Ensure your server and client are using the same Builder API credentials

Source Code

The complete source code and additional examples are available on GitHub:

Support

For assistance with the builder signing server: