@solpredict/cli
v0.2.1
Published
Command-line interface and Claude/MCP plugin for trading on SolPredict prediction markets on Solana.
Maintainers
Readme
@solpredict/cli
Command-line interface and Claude/MCP plugin for trading on SolPredict prediction markets on Solana.
SolPredict CLI lets you inspect markets, quote trades, manage funds and margin, place orders, and bootstrap Claude/MCP agents from one local-signing command line.
Install
npm install -g @solpredict/cliRequires Node >=20.19.0 <21.
Quickstart
solpredict --info
solpredict wallet show --network devnet
solpredict markets list --network devnet --limit 10
solpredict markets quote 1 --side buy --outcome yes --size 100 --price 5500For state-changing commands, add the flags you want and review the confirmation prompt:
solpredict trade buy 1 --outcome yes --size 100 --price 5500 --network devnetWhat You Can Do
| Area | Commands |
| --- | --- |
| Discovery | solpredict --info, solpredict info, solpredict instructions, solpredict banner |
| Setup | setup status, setup cash, setup margin |
| Wallet and funding | wallet show, wallet airdrop, balance, funding deposit, funding withdraw, funding show |
| Markets | markets list, markets show, markets quote, markets orderbook, markets trades, markets create |
| Trading | trade buy, trade sell, trade cancel, trade match, orders list, orders show, orders cleanup, orders close |
| Positions and PnL | positions list, positions show, positions close, leaderboard top |
| Liquidity | liquidity provide, liquidity remove, liquidity claim-fees, liquidity close, liquidity show |
| Margin | margin init, margin status, margin deposit, margin withdraw, margin provide-liquidity, margin remove-liquidity, margin close-position, margin close-order, margin cancel-close-order, margin close-liquidity, margin close-account |
| Resolution | resolution show, resolution challenge, resolution claim-bond, resolution settle-batch, resolution claim-creator |
| Protocol | protocol show |
Safety Model
- Keys stay local. The CLI loads a Solana keypair from your configured path or environment and signs on your machine.
- State-changing commands prompt before submitting.
--yesis available only when you intentionally want non-interactive execution. - Mainnet requires an additional typed
mainnetconfirmation. wallet airdroprefuses to run on mainnet.- Use
markets quotebeforetrade buyortrade sellso cost/proceeds are explicit before signing.
Configuration
Global flags:
| Flag | Description |
| --- | --- |
| --keypair <path> | Path to a Solana keypair JSON file. |
| --network <net> | devnet (default), mainnet-beta, or testnet. |
| --rpc-url <url> | Override the network RPC endpoint. |
| --api-url <url> | Override the off-chain API endpoint for API-backed commands. |
| --output text\|json | Output format. Default: text. |
| --yes | Skip the confirmation prompt on state-changing commands. |
| --collateral-mint <pk> | Override the collateral mint where applicable. |
Wallet resolution order:
--keypair <path>SOLPREDICT_KEYPAIRANCHOR_WALLETSOLPREDICT_KEYPAIR_BASE64~/.config/solana/id.json
Network and RPC defaults:
| Source | Default |
| --- | --- |
| --network / SOLPREDICT_NETWORK / NEXT_PUBLIC_SOLANA_NETWORK | devnet |
| --rpc-url / SOLPREDICT_RPC_URL / NEXT_PUBLIC_SOLANA_RPC_URL | network default RPC |
| --api-url / SOLPREDICT_API_URL / NEXT_PUBLIC_API_URL | unset |
AI Agent Setup
The package supports three AI setup paths:
claude plugin install solpredict
solpredict instructions | pbcopy
node ./node_modules/@solpredict/cli/dist/mcp/server.jsUse solpredict instructions --format=json when a client wants a structured
setup contract. The contract includes safety rules, unit conversions, workflows,
command metadata, and MCP details.
The package also ships a Claude plugin manifest (plugin/plugin.json),
slash-command docs (plugin/commands), and skill guidance
(plugin/skills/solpredict/SKILL.md). The MCP stdio server is exported as
@solpredict/cli/mcp and exposes a read-only solpredict_instructions tool.
Safety rules for every assistant:
- Never read, print, summarize, log, paste, or expose keypair file contents.
- Use
--output jsonfor machine-readable reads. - Quote before trades.
- Confirm every state-changing command before running it.
- Surface mainnet before signing.
- Relay on-chain error code and Anchor error name verbatim.
Command Examples
Discovery
solpredict --info
solpredict info margin
solpredict bannerOnboarding
solpredict wallet airdrop --sol 1 --network devnet
solpredict setup status
solpredict setup cash --amount 10.0
solpredict setup margin --amount 25.0Markets and Trading
solpredict markets list --limit 10
solpredict markets show 1
solpredict markets orderbook 1 --depth 10
solpredict markets quote 1 --side buy --outcome yes --size 100 --price 5500
solpredict trade buy 1 --outcome yes --size 100 --price 5500
solpredict trade sell 1 --outcome yes --size 50 --price 6000
solpredict trade cancel 1 42
solpredict trade match 1 --yes-order 42 --no-order 43Funding, Liquidity, and Margin
solpredict funding deposit --amount 1.0
solpredict funding withdraw --amount 0.5
solpredict funding show
solpredict liquidity provide 1 --amount 5.0
solpredict liquidity claim-fees 1
solpredict liquidity remove 1 --shares 2.0
solpredict margin status
solpredict margin deposit --amount 10.0
solpredict margin withdraw --amount 5.0
solpredict margin provide-liquidity --amount 5.0
solpredict margin remove-liquidity --shares 2.0
solpredict margin close-position 1 --outcome yes
solpredict margin close-order 1 --outcome yes --price 55 --size 1000000
solpredict margin cancel-close-order 1 42 --outcome yes
solpredict margin close-liquidityResolution and Protocol
solpredict resolution show 1
solpredict resolution challenge 1 --outcome no --evidence-url <url>
solpredict resolution claim-bond 1 --challenge-index 0
solpredict resolution settle-batch 1 --owner <pubkey> --owner <pubkey>
solpredict protocol show
solpredict leaderboard top --sort pnl --limit 20Output Formats
All commands accept --output text|json. JSON output stringifies BigInt, BN, and PublicKey values so downstream tools can parse command output without precision loss.
Amount Parsing
Funding, liquidity, margin, and setup commands accept --amount and --shares in two forms:
- Decimal, such as
--amount 1.25, parsed against the collateral mint decimals. - Raw integer, such as
--amount 1250000, interpreted as minor units.
Both interpretations are echoed in confirmation output before a transaction is submitted.
Development
From the monorepo:
pnpm install
pnpm --filter @solpredict/cli build
node packages/cli/dist/bin/solpredict.js --helpThe build writes:
packages/cli/dist/bin/solpredict.js- executable CLI binary.packages/cli/dist/mcp/server.js- MCP stdio server.
Development checks:
pnpm --filter @solpredict/cli test
pnpm --filter @solpredict/cli typecheckPublished Install Certification
The published npm package (not the repo dist) is certified end-to-end against an isolated Node 20.19.x install:
# NODE20_BIN points at a Node 20.19.x bin dir (see the runbook for the path).
export PATH="$NODE20_BIN:$PATH"
export SOLPREDICT_CLI_PUBLISHED_NODE20="$NODE20_BIN/node"
export SOLPREDICT_CLI_PUBLISHED_NPM20="$NODE20_BIN/npm"
export SOLPREDICT_CLI_PUBLISHED_KEYPAIR_A=/path/to/devnet-trader-a.json
pnpm test:e2e:cli:published:readonlyEvidence is written to artifacts/cli-published-install-certification/$RUN_ID/.
See docs/runbooks/CLI_PUBLISHED_INSTALL_CERTIFICATION.md for read-only, full
stateful, skip-install, and host-distribution modes.
