Do not treat Polygon Amoy as a public Polymarket trading sandbox: the available references do not establish a supported end-to-end test environment for market discovery, order submission, matching, and settlement. Amoy is a Polygon testnet, so it can verify wallet and contract behavior for deployments you control or have independently verified. Use local fixtures for order and feed logic, then validate real API schemas and settlement data with read-only production checks. This guide shows how to run those checks and identify what each one actually proves.
Polymarket testnet scope
If you need a testnet RPC for your own contracts, use Polygon Amoy. If you need a Polymarket sandbox where test orders match and settle, an Amoy RPC URL is not enough. Before relying on a hosted test environment, look for a matching CLOB host, authentication instructions, test market and outcome-token IDs, and settlement contracts in the current Polymarket developer documentation. Those details need to describe the same environment. If you cannot verify them, keep order submission in a local mock.
A reference to an Amoy exchange address can point you toward an on-chain deployment to inspect, but it does not establish that a hosted matching engine accepts orders for that deployment. Similarly, a hackathon project with the same name on Mumbai or Scroll does not establish support from Polymarket. An SDK accepting a chain ID is also not evidence that the remote service supports it.
Market data, matching, and settlement boundaries
Polymarket’s integration has distinct surfaces. Gamma provides market discovery and metadata. The central limit order book (CLOB) provides order-book data and handles trading requests; WebSocket feeds deliver real-time updates. The Data API provides another view of activity and positions. Polygon RPC reads blockchain state and settlement evidence. Changing the RPC URL does not change the environment used by any of the hosted APIs.
Keep identifiers distinct in your data model. A market or condition identifier is not the outcome-token ID used to select a book, and a CLOB order ID is not a transaction hash. Store outcome-token IDs as strings to avoid losing precision in JavaScript. Treat order acknowledgment, reported fills, and observed on-chain settlement as separate states. An accepted order might remain open, and a fill report alone does not tell you whether your RPC reader has observed the relevant block.
Test prerequisites and environment separation
Use three explicit modes: local replay, Amoy contract testing, and Polygon mainnet read-only validation. The examples need a shell with curl, Python 3, and an RPC URL appropriate to the mode. Neither example needs a wallet, faucet funds, or API credentials. Add a disposable signer only if you deliberately run transaction tests against contracts on Amoy.
Keep the RPC URL, expected chain ID, API base URLs, contract addresses, and write permissions in one environment profile. Make write permissions default to off. For read-only production tests, omit signing keys and trading credentials, and allowlist read methods in your API and RPC clients so a configuration mistake cannot turn a test into a submission. See the network directory for chain context and the Learn library for integration patterns.
RPC chain identity and contract verification
Run this in a POSIX-compatible shell after replacing RPC_URL. Leave CONTRACT_ADDRESS empty to check only the network, or use an address independently verified for the selected chain. The expected eth_chainId result is 0x13882 for Polygon Amoy (80002) or 0x89 for Polygon PoS mainnet (137). Compare the result before inspecting any contract. The || exit 1 handles transport or HTTP failures; it does not detect a JSON-RPC error returned with HTTP 200.
- If the response has an
errorfield or the chain ID differs from your profile, stop. In CI, parse the JSON and fail the test on either condition. - An
eth_getCoderesult of0xmeans there is no bytecode at that address at the queried block. A nonempty result establishes only that bytecode exists; verify the expected deployment and, for a proxy, its implementation. - Even verified exchange bytecode does not prove that a Polymarket CLOB host routes orders to it. Test contract behavior and hosted-service compatibility separately.
RPC_URL='REPLACE_WITH_RPC_URL'
CONTRACT_ADDRESS=''
rpc() {
curl --silent --show-error --fail --max-time 15 \
-H 'Content-Type: application/json' --data "$1" "$RPC_URL"
}
rpc '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}' || exit 1
printf '\n'
if [ -n "$CONTRACT_ADDRESS" ]; then
rpc "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"eth_getCode\",\"params\":[\"$CONTRACT_ADDRESS\",\"latest\"]}"
printf '\n'
fiDeterministic order-book replay
Start with a normalized fixture that tests your own feed logic without relying on live liquidity. The example below uses synthetic sequence numbers and a connection-generation marker added by the application. Neither is a claim about fields in Polymarket’s WebSocket payload. It checks that a delta cannot initialize the book, a gap invalidates the cached state, and updates from a previous connection cannot mutate the replacement snapshot.
- Expect the
PASSline. Then replace the illustrative events with sanitized captures and test your production parser separately from the state reducer. - Only do sequence-gap detection against a feed that documents suitable sequence semantics. Otherwise, test recovery by forcing a disconnect and withholding stale data until a fresh snapshot is installed.
- Use separate order fixtures for validation failures, partial fills, and ambiguous submission timeouts. Test that an unknown outcome triggers reconciliation rather than a blind retry.
python3 - <<'PY'
def apply(state, current_connection, event):
connection, kind, seq, best_bid = event
if connection != current_connection:
return state
if kind == 'snapshot':
return (seq, best_bid)
if state is None:
return None
if seq <= state[0]:
return state
if seq != state[0] + 1:
return None
return (seq, best_bid)
state = apply(None, 1, (1, 'delta', 9, '0.40'))
assert state is None
state = apply(state, 1, (1, 'snapshot', 10, '0.41'))
state = apply(state, 1, (1, 'delta', 11, '0.42'))
assert state == (11, '0.42')
assert apply(state, 1, (1, 'delta', 11, '0.99')) == state
state = apply(state, 1, (1, 'delta', 13, '0.43'))
assert state is None
state = apply(state, 2, (2, 'snapshot', 20, '0.44'))
assert apply(state, 2, (1, 'delta', 21, '0.99')) == (20, '0.44')
print('PASS: snapshot, duplicate, gap, and reconnect checks')
PYRead-only production verification
Select one active market using the documented discovery API. Save its market identifier, outcome labels, and outcome-token mapping. Fetch the public CLOB snapshot for one mapped token and check that the token and outcome stay associated throughout your pipeline. Connect to the documented market-data feed, force a disconnect, and verify that the client rebuilds its book state before displaying fresh prices. An empty book is a valid test case; it does not by itself indicate a broken endpoint.
For settlement validation, use a separate historical example with a known Polygon transaction hash. Fetch its receipt with eth_getTransactionReceipt, check the receipt status, and decode the relevant logs with the verified ABI for the emitting contract. Record the block number and block hash. This verifies that your reader interprets a known settlement transaction; it does not verify that your client can authenticate, place, match, or cancel an order.
Reproducible measurement and acceptance criteria
Measure the hosted API and Polygon RPC separately so a slow snapshot is not attributed to the chain. For a fixed read workload, record the test window, client region, method or route, sample count, request rate, concurrency, timeout, and retry policy. Report the median and p95 of successful requests alongside failure counts, with timeouts, rate limits, and JSON-RPC errors classified separately. For reconnect recovery, measure from the observed disconnect to the installation of a fresh snapshot, not merely to the reopening of the socket.
| Check | Hold constant | Record from your run |
|---|---|---|
| CLOB snapshot read | Route, outcome token, request schedule | Attempts, errors, median and p95 latency |
| Feed reconnect | Market subscription, disconnect method, recovery rule | Time to usable snapshot, recovery failures |
| Polygon receipt read | Transaction hash, chain, client region | Latency, receipt status, block hash, decoded event result |
Set acceptance thresholds before the run based on how stale your application can safely be. If you later compare hosted RPC with a dedicated node, reuse the same workload and check RPC plan limits for the setup you actually test. Neither deployment model changes whether Polymarket provides a trading sandbox.
Failure isolation and troubleshooting
Identify the layer that produced the failure before changing endpoints. Capture the environment name, request method, status or RPC error, and the market or transaction identifier as appropriate. Redact authorization headers, signing material, and any credentials embedded in RPC URLs.
- Wrong chain ID or empty bytecode: check the RPC profile and deployment record before debugging the ABI or wallet. If you suspect a configuration issue, review the RPC access documentation.
- Market exists but the book is missing: check the outcome-token mapping, market status, and route. Querying a condition ID as though it were an outcome-token ID is an application error, not an RPC outage.
- Signature rejected: compare the configured chain, signer and funder roles, signature type, and signing domain with the current trading documentation. Do not switch to production or fund a wallet just to see whether a test signature works.
- Receipt is
null: check the transaction hash and chain first. For recent activity, a receipt may not yet be visible; poll within a bounded window. When your application requires confirmation, recheck the recorded block hash against the canonical chain.
Coverage limits and release gates
Mocks cover your logic and let you reproduce rare failures. Amoy covers chain interactions such as wallet selection, token approvals for your test deployment, transaction receipts, and event decoding. Read-only production checks cover live formats, availability, and observed chain data. None of those, individually or together, proves that the hosted trading service will accept a signed order from your account or that it will fill.
Keep writes disabled until the offline suite and read-only checks pass. If a release genuinely requires live trading validation and no supported sandbox is documented, treat it as a separate production change: confirm eligibility and platform terms, use an isolated account with explicit exposure limits, and plan for the order to fill before cancellation. If live validation is not authorized, leave writes disabled and mark hosted order acceptance as unverified.