Skip to content

Openfish CLI

Terminal window
brew tap Openfish/openfish-cli https://github.com/Openfish/openfish-cli
brew install openfish
Terminal window
curl -sSL https://raw.githubusercontent.com/Openfish/openfish-cli/main/install.sh | sh

Requires Rust 1.88+.

Terminal window
git clone https://github.com/Openfish/openfish-cli
cd openfish-cli
cargo install --path .
Terminal window
openfish upgrade
# or
brew upgrade openfish
Terminal window
openfish --version # prints version
openfish status # checks API connectivity

The guided setup wizard handles wallet creation and contract approvals in one step:

Terminal window
openfish setup

Or do it manually:

Terminal window
# 1. Create or import a wallet
openfish wallet create
# or
openfish wallet import 0xYOUR_PRIVATE_KEY
# 2. Approve Openfish contracts (needs MATIC for gas)
openfish approve set
# 3. Check your balance
openfish clob balance --asset-type collateral

The CLI looks for your private key in this order:

  1. --private-key 0x... flag
  2. OPENFISH_PRIVATE_KEY environment variable
  3. Config file at ~/.config/openfish/config.json

Config file format:

{
"private_key": "0x...",
"chain_id": 137,
"signature_type": "proxy"
}

Security: Never commit your private key to source control. Use environment variables or the config file. The config file is created with 600 permissions.

TypeDescriptionGas
proxy (default)Openfish proxy walletGasless (relayer pays)
eoaDirect wallet signingYou pay gas in MATIC
gnosis-safeGnosis Safe multisigGasless (relayer pays)

Override per-command: --signature-type eoa or OPENFISH_SIGNATURE_TYPE=eoa.

Most read operations work without a wallet:

No wallet neededWallet required
Browse marketsPlace/cancel orders
View order booksCheck your balances
Check pricesOn-chain operations (approve, split, merge, redeem)
View leaderboardsAPI key management
Search eventsBridge operations

Every command supports two output modes:

Terminal window
# Human-readable table (default)
openfish markets list --limit 3
# Machine-readable JSON (for scripts and integrations)
openfish -o json markets list --limit 3

Short form: -o json or --output json.

Errors follow the same pattern: table mode prints Error: ... to stderr, JSON mode prints {"error": "..."} to stdout. Non-zero exit code in both cases.


Terminal window
# Browse active markets
openfish markets list --limit 10
openfish markets list --active true --order volume_num
# Search by keyword
openfish markets search "bitcoin" --limit 5
# Get market details
openfish markets get will-trump-win-the-2024-election
openfish markets get 12345

Events group related markets (e.g., “2024 Election” contains multiple yes/no markets).

Terminal window
openfish events list --limit 10
openfish events list --tag politics --active true
openfish events get 500
Terminal window
openfish tags list
openfish tags get politics
openfish series list --limit 10

All read-only, no wallet needed.

Terminal window
# Single token
openfish clob price <token_id> --side buy
openfish clob midpoint <token_id>
openfish clob spread <token_id>
openfish clob book <token_id>
# Batch (comma-separated)
openfish clob batch-prices "TOKEN1,TOKEN2" --side buy
openfish clob midpoints "TOKEN1,TOKEN2"
openfish clob books "TOKEN1,TOKEN2"
# Price history
openfish clob price-history <token_id> --interval 1d --fidelity 30

Intervals: 1m, 1h, 6h, 1d, 1w, max


Requires a configured wallet.

Terminal window
# Limit order: buy 10 shares at $0.50
openfish clob create-order \
--token <token_id> \
--side buy --price 0.50 --size 10
# Market order: buy $5 worth
openfish clob market-order \
--token <token_id> \
--side buy --amount 5
# Batch orders
openfish clob post-orders \
--tokens "TOKEN1,TOKEN2" \
--side buy \
--prices "0.40,0.60" \
--sizes "10,10"

Order types: GTC (default, Good Till Cancelled), FOK (Fill Or Kill), GTD (Good Till Date), FAK (Fill And Kill). Add --post-only for limit orders that should only add liquidity.

Terminal window
openfish clob cancel <order_id>
openfish clob cancel-orders "ORDER1,ORDER2"
openfish clob cancel-market --market <condition_id>
openfish clob cancel-all
Terminal window
openfish clob orders
openfish clob orders --market <condition_id>
openfish clob order <order_id>
openfish clob trades
Terminal window
openfish clob balance --asset-type collateral
openfish clob balance --asset-type conditional --token <token_id>

Split, merge, and redeem conditional tokens on-chain. Requires MATIC for gas.

Terminal window
# Split $10 USDC into YES + NO tokens
openfish ctf split --condition <condition_id> --amount 10
# Merge YES + NO tokens back to USDC
openfish ctf merge --condition <condition_id> --amount 10
# Redeem winning tokens after market resolution
openfish ctf redeem --condition <condition_id>

--amount is in USDC (e.g., 10 = $10.00).


Before trading, Openfish contracts need ERC-20 (USDC) and ERC-1155 (CTF) token approvals.

Terminal window
# Check current approval status
openfish approve check
# Approve all contracts (sends 6 on-chain transactions)
openfish approve set

Public data, no wallet needed.

Terminal window
# Your positions
openfish data positions <wallet_address>
openfish data closed-positions <wallet_address>
openfish data value <wallet_address>
# Trade history
openfish data trades <wallet_address> --limit 50
# Market analytics
openfish data holders <condition_id>
openfish data open-interest <condition_id>
# Leaderboards
openfish data leaderboard --period month --order-by pnl --limit 10

Terminal window
openfish clob api-keys # List your API keys
openfish clob create-api-key # Generate a new key
openfish clob delete-api-key # Revoke an existing key

Move assets between Openfish and other chains.

Terminal window
openfish bridge deposit <wallet_address> # Get deposit addresses
openfish bridge supported-assets # List supported chains/tokens
openfish bridge status <deposit_address> # Check deposit status

Terminal window
openfish wallet create # Generate new wallet
openfish wallet import <key> # Import existing private key
openfish wallet address # Print wallet address
openfish wallet show # Full wallet info
openfish wallet reset # Delete config (prompts confirmation)

Launch a REPL for quick exploration:

Terminal window
openfish shell
openfish> markets list --limit 3
openfish> clob book <token_id>
openfish> exit

All commands work the same as the CLI, just without the openfish prefix. Supports command history.


Terminal window
openfish -o json markets list --limit 100 | jq '.[].question'
Terminal window
openfish -o json clob midpoint <token_id> | jq '.mid'
Terminal window
if ! result=$(openfish -o json clob balance --asset-type collateral 2>/dev/null); then
echo "Failed to fetch balance"
exit 1
fi
echo "Balance: $(echo $result | jq '.balance')"
Terminal window
while true; do
price=$(openfish -o json clob midpoint $TOKEN | jq -r '.mid')
if (( $(echo "$price < 0.30" | bc -l) )); then
openfish clob market-order --token $TOKEN --side buy --amount 10
echo "Bought at $price"
fi
sleep 60
done

Terminal window
openfish markets search "bitcoin" --limit 5
openfish markets get bitcoin-above-100k
openfish clob book <token_id>
openfish clob price-history <token_id> --interval 1d
Terminal window
openfish wallet create
openfish approve set # needs MATIC for gas
openfish clob balance --asset-type collateral
openfish clob market-order --token <token_id> --side buy --amount 5
Terminal window
openfish data positions <your_address>
openfish data value <your_address>
openfish clob orders
openfish clob trades

ProblemSolution
Error: no private key configuredRun openfish wallet create or set OPENFISH_PRIVATE_KEY
Error: insufficient allowanceRun openfish approve set
Error: insufficient balanceDeposit USDC.e to your Polygon wallet
Error: connection refusedCheck openfish status, API may be down
Error: insufficient gasSend MATIC to your wallet for on-chain operations
Command not foundVerify installation with which openfish