Skip to main content

polyrails

The Polymarket CLOB V2 execution layer that works.

Since the 2026 deposit-wallet migration, new accounts get 400 "maker address not allowed" / "invalid order version" from the legacy SDK paths most tutorials still show (py-clob-client-v2 #70 and friends). The working path is the official unified polymarket SDK over the gasless deposit-wallet flow — but wiring it correctly (EOA → derived API creds → AsyncSecureClient → setup_gasless_wallet → orders) is undocumented folklore.

polyrails is that folklore, packaged: private key in, working orders out.

import asyncio
from polyrails import Rails

async def main():
    r = await Rails.connect(private_key="0x...")      # no website, no manual API keys
    print(r.wallet, await r.balance())                # your V2 deposit wallet + pUSD balance
    res = await r.limit("TOKEN_ID", "BUY", price=0.42, size=10)
    print(res.ok, res.order_id)
    await r.close()

asyncio.run(main())

What it does

  • Derives API credentials from your EOA — no dashboard visit needed.
  • Binds your V2 Deposit Wallet (idempotent) and signs orders for it — the only order path the venue accepts for fresh accounts since July 2026.
  • Limit (incl. post-only) + market (FAK/FOK) orders, cancels, open orders, balances.
  • Market data: midpoint(), price(), spread(), book().
  • Price ticks conformed automatically (BUY rounds up as a marketable ceiling, SELL rounds down — you never lose edge to a tick rejection).
  • Attribution verification built in: builder_fills() returns the venue's own ledger of trades credited to a builder code.
  • Clear, honest errors instead of cryptic 400s.

What it never does

  • Never custodies keys or funds. Your key stays in your process, used only for local signing. There is no polyrails server. (The two biggest hosted Polymarket bots were hacked for −$70k and −$230k in 2026. Architecture is the fix: there is nothing here to hack.)
  • Never places an order you didn't call for.

Funding disclosure

Orders placed through polyrails carry a builder attribution code — a public identifier in the signed order (that's Polymarket's official Builder Program). Attribution costs you nothing: polyrails sets no builder fee (0 bps, verifiable on-chain per order); the code only routes a share of Polymarket's builder rewards pool to whoever's code is attached. That's how free, non-custodial open source stays maintained.

Resolution order: Rails.connect(builder_code=...) → POLYRAILS_BUILDER_CODE env → the maintainer's code (polyrails, 0x7885f4b3b4c42bbee435fc16f66e7679b461610eb080c9985bdd9fdfd1bffd56). Registered builder? Pass your own code and keep the rewards. Want no attribution at all? Set builder_code="" (or env POLYRAILS_BUILDER_CODE=off).

Status

v0.1 — extracted from a private trading system and validated end-to-end on the live venue (order lifecycle + attribution CONFIRMED on the builder ledger; the whole validation cost $0.02). Gates and roadmap: GATES.md, CHANGELOG.md.

Install

pip install polyrails

Requires Python ≥ 3.11. MIT licensed.

Metadata

Release files for polyrails 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polyrails 0.1.0
File Size Uploaded
polyrails-0.1.0.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polyrails 0.1.0
File Interpreter ABI Platform
polyrails-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / polyrails-0.1.0.tar.gz

Download URL polyrails-0.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
06774eab4a27f6bbe533973ffedb26bac34f7a7ffc7d207ffde98db7d95865f8
BLAKE2b-256 checksum
How to use checksums
93f806585a9d9ed17a1fc9a4933d18d1bbed4388fc21aad64bee129d1426faeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / polyrails-0.1.0-py3-none-any.whl

Download URL polyrails-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2e811636f0038ca3386940fc5e26e4e885455d2cfd150a8b3f45e5cee2fc63b
BLAKE2b-256 checksum
How to use checksums
acb1cf8f02f20a35b138505a0918364a34f06adb24aac0f69691576c236c3f68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page