context-markets-cli
v0.3.0
Published
CLI for trading on Context prediction markets
Readme
Install
npm install -g context-markets-cliThis installs the context command globally.
Or run without installing:
npx context-markets-cli <command>Getting started
The fastest way to get set up:
context setupThis walks you through:
- Wallet -- generate a new wallet or import an existing private key
- Save credentials -- persists to
~/.config/context/config.env(chmod 600) - Authorize -- links your CLI wallet to your Context account
- Approve contracts -- checks ETH balance, approves on-chain (requires ETH on Base for gas)
- Deposit USDC -- checks USDC balance, deposits into the exchange
If anything fails (no ETH, rate limit, etc.), you can re-run context setup -- it detects your existing config and picks up where you left off.
Manual setup
If you prefer to configure manually:
# Option 1: Environment variables
export CONTEXT_API_KEY="your-api-key"
export CONTEXT_PRIVATE_KEY="0x..."
# Option 2: Config file (created by `context setup`)
# ~/.config/context/config.envCredentials are loaded in order: CLI flags > env vars > config file.
Need an API key? Visit context.markets or join our Discord.
Quick start
# Browse markets
context markets list --status active --limit 5
# Search for a market
context markets search "march madness"
# Get a link to a market
context markets link <market-id>
# View the orderbook
context markets orderbook <market-id>
# Place a limit order
context orders create --market <id> --outcome yes --side buy --price 45 --size 10
# Check your portfolio
context portfolio overview
# Interactive shell
context shellAgent workflow
The CLI supports a fully non-interactive JSON mode for AI agents:
# 1. Generate wallet and save to config
context setup --output json --save
# -> { "status": "new_wallet", "address": "0x...", "privateKey": "0x...", "configPath": "..." }
# 2. Authorize CLI wallet as a signer on your Context account
context account authorize --output json
# -> { "requestId": "...", "authorizeUrl": "https://...", "status": "pending" }
# 3. Approve contracts (after funding wallet with ETH on Base)
context account setup --output json
# -> { "status": "approved", "usdcApprovalTx": "0x...", "operatorApprovalTx": "0x..." }
# 4. Deposit USDC
context account deposit 100 --output json
# -> { "status": "deposited", "amount_usdc": 100, "tx_hash": "0x..." }
# 5. Trade
context orders create --market <id> --outcome yes --side buy --price 45 --size 10 --output jsonAll commands accept --output json for structured output. When piped (non-TTY), JSON is the default.
Commands
Markets -- markets list . markets search . markets get . markets link . markets quotes . markets orderbook . markets simulate . markets price-history . markets oracle . markets oracle-quotes . markets request-oracle-quote . markets activity . markets global-activity . markets create
Orders -- orders list . orders mine . orders get . orders recent . orders simulate . orders create . orders market . orders cancel . orders cancel-replace . orders bulk-create . orders bulk-cancel . orders bulk
Portfolio -- portfolio overview . portfolio get . portfolio claimable . portfolio stats . portfolio balance . portfolio token-balance
Account -- account status . account authorize . account setup . account deposit . account withdraw . account mint-test-usdc . account mint-complete-sets . account burn-complete-sets . account gasless-approve . account gasless-deposit
Questions -- questions submit . questions status . questions submit-and-wait . questions agent-submit . questions agent-submit-and-wait
Other -- setup . guides . shell . profile
Run context <command> help or context <command> --help for details on any command.
Key concepts
- Prices are in cents (1-99). A price of 65 means $0.65 per share.
- Outcomes are
yesorno. Each market is a binary question. - Output auto-detects: tables in a terminal, JSON when piped. Override with
--output jsonor--output table. - Read-only commands only need
CONTEXT_API_KEY. Trading commands also needCONTEXT_PRIVATE_KEY. - Interactive shell (
context shell) supports#Nrow references,next/backpagination, and all commands. - Profiles let you manage multiple configurations (e.g., testnet vs mainnet).
Guides
Built-in guides are available in the CLI:
context guides # List available guides
context guides trading # View the trading guideDocumentation
- Command Reference -- full list of commands with flags and response shapes
- CLI Guide -- setup, authentication, and workflows
- Agent Workflows -- common patterns for AI agent integration
Ecosystem
| Package | Description | | ------------------------------------------------------------------------ | --------------------------------------- | | context-markets | TypeScript SDK for trading | | context-markets-react | React hooks for market data and trading | | context-markets-mcp | MCP server for AI agents | | context-markets-cli | CLI for trading from the terminal | | context-skills | AI agent skill files | | context-plugin | Claude Code plugin |
License
MIT -- see LICENSE for details.
