Before you trade
Before you can place orders on Context, your wallet needs two things:
Operator approval — authorize the Settlement contract to manage your holdings
USDC deposit — move USDC into the Holdings contract so you have funds to trade
On testnet, both steps are gasless — the SDK handles this automatically. On mainnet, these are on-chain transactions.
Orders will fail if you skip this. The API returns a “not approved” error if your wallet isn’t set up, and orders require a funded Holdings balance.
Quick version (SDK)
If you’re using the SDK, it’s three steps:
import { ContextClient } from "context-markets"
const ctx = new ContextClient ({
chain: "testnet" ,
apiKey: process . env . CONTEXT_API_KEY ! ,
signer: { privateKey: process . env . PRIVATE_KEY ! as `0x ${ string } ` },
})
// 1. Approve contracts (gasless on testnet, on-chain on mainnet)
await ctx . account . setup ()
// 2. Deposit USDC (gasless on testnet, on-chain on mainnet)
await ctx . account . deposit ( 100 )
// Ready to trade
You only need to call setup() once per wallet. After that, deposit whenever you need more funds.
Step by step
1. Check your wallet status
Before doing anything, check whether your wallet already has the required approvals:
const status = await ctx . account . status ()
console . log ( "Address:" , status . address )
console . log ( "USDC balance:" , status . usdcBalance )
console . log ( "Ready to trade:" , status . isReady )
If isReady is true, skip to the deposit step.
2. Approve contracts
This authorizes the Settlement contract to transfer your holdings during order settlement. The SDK picks the right method based on chain:
const result = await ctx . account . setup ()
console . log ( "USDC approval:" , result . usdcApproval . txHash )
console . log ( "Operator approval:" , result . operatorApproval . txHash )
On testnet, your wallet signs an approval message and the Context relayer submits the transaction — no ETH needed. On mainnet, this sends on-chain transactions.
There may be a short indexer delay after approval. If your first order returns a “not approved” error, wait a few seconds and retry.
3. Deposit USDC
Move USDC from your wallet into the Holdings contract:
const result = await ctx . account . deposit ( 100 ) // deposit 100 USDC
console . log ( "Tx hash:" , result . txHash )
console . log ( "Gasless:" , result . gasless )
On testnet, this uses Permit2 (gasless). On mainnet, this is an on-chain transaction.
4. Verify
Confirm everything is ready:
const status = await ctx . account . status ()
console . log ( "Operator approved:" , status . isOperatorApproved )
console . log ( "USDC balance:" , status . usdcBalance )
console . log ( "Ready:" , status . isReady )
Using the API directly
If you’re not using the SDK, call the gasless endpoints directly:
Approve operator
Send a signed operator approval. See the API reference for the full request body schema.
Deposit with Permit2
POST /gasless/deposit-with-permit
Send a signed Permit2 deposit. See the API reference for the full request body schema.
Next steps
Place your first order Now that your wallet is ready, place your first trade
Account reference Full account module docs — withdrawals, complete sets, and more