Skip to main content

Before you trade

Before you can place orders on Context, your wallet needs two things:
  1. Operator approval — authorize the Settlement contract to manage your holdings
  2. TUSD deposit — move TUSD into the Holdings contract so you have funds to trade
Both steps are gasless — you sign messages but never pay gas. The Context relayer submits the transactions for you.
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 "@contextwtf/sdk"

const ctx = new ContextClient({
  apiKey: process.env.CONTEXT_API_KEY!,
  signer: { privateKey: process.env.PRIVATE_KEY! as `0x${string}` },
})

// 1. Approve contracts (gasless)
await ctx.account.gaslessSetup()

// 2. Mint test TUSD (testnet only, once per day)
await ctx.account.mintTestUsdc(1000)

// 3. Deposit TUSD (gasless)
await ctx.account.gaslessDeposit(100)

// Ready to trade
You only need to call gaslessSetup() once per wallet. After that, mint and 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("Needs approvals:", status.needsApprovals)
console.log("Operator approved:", status.isOperatorApproved)
console.log("TUSD allowance:", status.usdcAllowance)
If needsApprovals is false, skip to the deposit step.

2. Approve the operator (gasless)

This authorizes the Settlement contract to transfer your holdings during order settlement. It’s a one-time setup:
const result = await ctx.account.gaslessSetup()

console.log("Tx hash:", result.txHash)
console.log("Relayed by:", result.relayer)
Your wallet signs an approval message and the Context relayer submits the transaction on your behalf — no ETH needed.
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. Mint TUSD

On testnet, mint free TUSD before depositing:
await ctx.account.mintTestUsdc(1000) // mint 1000 TUSD
The mint endpoint can be called once per day per API key. This only works on Base Sepolia testnet.

4. Deposit TUSD (gasless)

Move TUSD from your wallet into the Holdings contract using Permit2. No gas required:
const result = await ctx.account.gaslessDeposit(100) // deposit 100 TUSD

console.log("Tx hash:", result.txHash)
console.log("Amount:", result.amount)
Your wallet signs a Permit2 message authorizing the transfer, and the relayer executes it.

5. Verify

Confirm everything is ready:
const status = await ctx.account.status()

console.log("Operator approved:", status.isOperatorApproved)
console.log("TUSD allowance:", status.usdcAllowance)

Using the API directly

If you’re not using the SDK, call the gasless endpoints directly:

Approve operator

POST /gasless/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