Prerequisites
You need Python 3.8 or later and three packages:Steps
1
Generate a wallet keypair
Use
eth_account.Account.create() to generate a fresh private key and address. In a production system you would load an existing private key from a secure secret store — never hardcode it.2
Build the signing helper
All See Authentication for the full typed-struct set and a line-by-line explanation of the signing process.
POST /exchange requests must be signed with EIP-712 (domain Exchange / v1 / chainId 9767). The signing struct depends on action.type: funds and permission actions (registerAccount, approveAgent, revokeAgent, lockCollateral, unlockCollateral, transferBetweenDeployers) use a field-level typed struct; everything else uses the Agent path, which folds canonical JSON into an actionHash.3
Register your account
Before you can trade, you must register your address on the exchange. This is a one-time operation per address.
Some environments require an
inviteCode field at the top level of the envelope (not inside action) for registerAccount. If registration returns INVITE_CODE_INVALID, add "inviteCode": "<your-code>" to the envelope dictionary alongside "action", "signature", and "nonce". The invite code is not included in the signed message.4
Place a limit buy order
Place a limit GTC (Good Till Cancelled) buy order for 10 units of SOL1 at a price of 50 USDT1. On testnet, price and size must be positive integers and price must not exceed 10000.
5
Verify the order
Confirm the order is live by querying
POST /info with userOrders. No signing is required for read queries.6
Cancel the order
Cancel the order using its
oid. Provide the asset ID (a) and order ID (o) in the cancels array.