pmxt-core server — moving to hosted mode is mostly additive. The SDK surface is unchanged; the constructor takes new arguments; a few read methods change their data source. This guide enumerates every observable difference so you can audit your code before flipping the switch.
This is a port of sdks/python/MIGRATION.md and sdks/typescript/MIGRATION.md with extra context. The original notes are tagged with the SDK version that introduced each change (2.18.0 and later).
TL;DR
- Get a
pmxt_api_keyfrom pmxt.dev/dashboard. - Pass
pmxt_api_key,wallet_address,private_keyto the exchange constructor. - Approve + deposit USDC into PreFundedEscrow once (
client.escrow.approve_tx,client.escrow.deposit_tx). - Audit
fetch_balance()consumers — the source changed. - Audit
Positionfield consumers — four fields are now Optional. - Catch the new
HostedTradingErrortree where you used to catch broadException.
1. Constructor — new arguments
In venue-direct mode you’d construct a Polymarket client with a raw private key only. In hosted mode you also passpmxt_api_key and an explicit wallet_address.
wallet_address argument is new in hosted mode and is required for any client.escrow.* call — the SDK uses it to scope all escrow operations to a single user. If you’ve been deriving the address from the private key implicitly, make it explicit.
2. Trust model — pmxt_api_key is a service-role credential
pmxt_api_key is not app-scoped per-user auth. The key holder can:
- Read any user’s escrow data (balance, positions, trades) by passing a different
wallet_address. - Forward signed orders for any wallet (the signature still gates the write).
fetch_balance, fetch_positions, etc.) are NOT gated by signature.
Treat pmxt_api_key as a backend secret. Keep it on a server. Never ship it to a browser bundle. Never log it.
If your previous architecture had end-user private keys on the server, hosted mode lets you flip that — keep pmxt_api_key on the server and push private keys to the client, where they’re signed locally and never leave the device.
3. fetch_balance — semantic change
The shape of the Balance object is unchanged, but the source is different.
| Mode | Source |
|---|---|
Venue-direct (pmxt_api_key=None) | Wallet’s CLOB-proxy USDC balance at the venue |
Hosted (pmxt_api_key set) | Wallet’s USDC balance in PMXT’s PreFundedEscrow on Polygon |
4. Position fields now Optional
Four fields on Position became Optional in 2.18.0. Venue-direct mode still populates them; hosted mode returns None / undefined when the server doesn’t have the data yet.
market_id, outcome_id, quantity, side, notional are still required and always populated.
5. New error tree
Hosted mode introducesHostedTradingError and a suite of semantic-parent subclasses. The parents are the same classes used in venue-direct mode (InsufficientFunds, InvalidOrder, AuthenticationError, etc.), so existing except/catch clauses keep working.
6. Escrow setup — new one-time step
Before your first hosted trade, USDC has to be in the PreFundedEscrow contract.7. Catalog UUIDs replace venue-native IDs in trading calls
Venue-direct trading lets you pass venue-native IDs (Polymarket condition IDs, token IDs). Hosted trading requires catalog UUIDs. The simplest path: discover markets via the Router instead of viaclient.fetch_markets, since the Router returns UUIDs natively.
See Catalog UUID vs venue ID for the reverse-resolution workaround if you already have venue-native IDs in your database.
8. Network surface
Venue-direct mode talks to a localpmxt-core server, which talks to venue APIs directly. Hosted mode talks to trade.pmxt.dev and api.pmxt.dev. Make sure both are reachable from your runtime if you flip — corporate firewalls that allow only api.pmxt.dev will need trade.pmxt.dev added.
Rollback plan
If you migrate and need to roll back, drop thepmxt_api_key argument. The SDK falls back to venue-direct mode and routes to the local pmxt-core server. No other changes needed. You’ll lose the escrow funds until you withdraw them via client.escrow.withdraw_tx, but the venue-native trading flow is unchanged.
See also
- Trading quickstart — 60-second guided path.
- Escrow lifecycle — deposit, withdraw, claim.
- Hosted errors — error class reference and recovery.
- Self-hosted — when not to migrate.

