Skip to content

Setup

Before setting up the signing server, ensure you have:

  • Bun runtime >= 1.3.x
  • Polymarket API credentials (key, secret, passphrase)
  • Builder Program access (optional, but required for rebates)

If you don’t have Bun installed, please follow the instructions here

Terminal window
# Check installation
bun --version
Terminal window
git clone https://github.com/roushou/polys.git
cd polys/apps/server
Terminal window
bun install

The signing server uses environment variables for configuration. Create a .env file:

Terminal window
cp .env.example .env

Edit the .env file with your credentials:

Terminal window
# Required - Polymarket API Credentials
POLYS_POLYMARKET_API_KEY=your_api_key
POLYS_POLYMARKET_SECRET=your_base64_secret
POLYS_POLYMARKET_PASSPHRASE=your_passphrase
# Required - Server Authentication (comma-separated list)
POLYS_API_TOKENS=token1,token2,token3
# Optional - Server Configuration
POLYS_SERVER_HOSTNAME=127.0.0.1
POLYS_SERVER_PORT=8080

POLYS_POLYMARKET_API_KEY

  • Your Polymarket API key
  • Obtained from the Polymarket builder dashboard
  • Used for signing order requests

POLYS_POLYMARKET_SECRET

  • Your Polymarket API secret (Base64 encoded)
  • Keep this extremely secure
  • Used for HMAC-SHA256 signature generation

POLYS_POLYMARKET_PASSPHRASE

  • Your Polymarket API passphrase
  • Set when creating your API credentials

POLYS_API_TOKENS

  • Comma-separated list of bearer tokens for authenticating requests to the signing server
  • Clients must include one of these tokens in the Authorization header
  • Supports multiple tokens for token rotation or multiple clients

POLYS_SERVER_HOSTNAME

  • Server hostname or IP address
  • Default: 127.0.0.1 (localhost)
  • Use 0.0.0.0 to listen on all interfaces

POLYS_SERVER_PORT

  • Server port number
  • Default: 8080
  • Choose an available port on your system

Generate cryptographically secure API tokens:

Terminal window
# Using OpenSSL (recommended)
openssl rand -base64 32
# Using Bun
bun -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
# Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"

You can generate multiple tokens and add them to POLYS_API_TOKENS as a comma-separated list:

Terminal window
POLYS_API_TOKENS=token1_here,token2_here,token3_here

This allows you to:

  • Rotate tokens without downtime (add new token, update clients, remove old token)
  • Issue different tokens for different clients or environments
  • Revoke individual tokens without affecting others

Start the server in development mode:

Terminal window
bun run dev

You should see output indicating the server is running:

Server running at http://127.0.0.1:8080

Check if the server is responding:

Terminal window
curl http://127.0.0.1:8080/health

Expected response:

{"status":"ok"}

Now that your signing server is configured:

  1. Deploy to Production - Choose a deployment method
  2. Configure Your Client - Integrate with your application
  3. Troubleshooting - Solve common issues

If port 8080 is already in use:

Terminal window
# Change the port in .env
POLYS_SERVER_PORT=5000