Overview
This guide walks you through a complete Java implementation for trading on Limitless Exchange: authentication, fetching market data, building and signing orders with EIP-712 via Web3j, and submitting them via the REST API.Prerequisites
Create a Gradle project
Initialize a Gradle project with the following dependencies in
build.gradle:build.gradle
Environment Variables
Configure the following before running:| Variable | Description |
|---|---|
PRIVATE_KEY | Your wallet private key (with or without 0x prefix) for EIP-712 signing |
API_KEY | API key from Limitless (starts with lmts_) |
API_URL | Optional; defaults to https://api.limitless.exchange |
OWNER_ID | Your profile ID (obtain from portfolio or auth endpoints) |
Authentication
All API requests require theX-API-Key header. Cookie-based session auth is deprecated.
Your private key is used only for EIP-712 order signing. The API key handles request authentication. Both are required for trading.
Fetching Market Data
UseGET /markets/:slug to retrieve market details, including venue addresses and position IDs. Cache this data per market; it is static.
Building Order Payloads
Orders require specific fields. Key values:| Field | Value | Description |
|---|---|---|
side | 0 | BUY |
side | 1 | SELL |
signatureType | 0 | EOA wallet |
orderType | GTC | Good Till Cancelled |
orderType | FOK | Fill or Kill |
BUY order
BUY order
You pay USDC, receive shares. Use Example: BUY 10 YES shares at $0.65 →
positionIds[0] for YES, positionIds[1] for NO.makerAmount = 6,500,000, takerAmount = 10,000,000SELL order
SELL order
You pay shares, receive USDC. Use the token ID of the shares you are selling.Example: SELL 10 YES shares at $0.65 →
makerAmount = 10,000,000, takerAmount = 6,500,000EIP-712 Signing
Sign orders using Web3j’sStructuredDataEncoder and Sign.signTypedData. The venue’s exchange address is the verifyingContract.
See EIP-712 Order Signing for the full type definition and field reference.
All addresses must be checksummed (EIP-55). Use
Keys.toChecksumAddress().Submitting Orders
Send the signed order toPOST /orders:
Complete Example
Build and Run
Troubleshooting
401 Unauthorized
Ensure
X-API-Key is set correctly and the key starts with lmts_. Check that the key is active in the Limitless UI.400 Invalid order / signature mismatch
- Verify
verifyingContractis the market’svenue.exchangeaddress. - Ensure all addresses are checksummed (EIP-55) via
Keys.toChecksumAddress(). - Confirm
makerAmountandtakerAmountuse 1e6 scaling for USDC and shares.
Insufficient balance or allowance
- Ensure you have enough USDC on Base for BUY orders.
- Approve USDC to
venue.exchangefor BUY; Conditional Tokens tovenue.exchange(andvenue.adapterfor NegRisk SELL) for SELL.