hunch-agent
v0.4.1
Published
One-line CLI to bet Hunch prediction markets from any terminal or script: discover, research, quote, simulate for $0, settle real USDC bets on Base via x402, watch resolutions live, or run the tested continuous strategy 24×7.
Downloads
679
Maintainers
Readme
hunch-agent
One-line CLI to bet Hunch prediction markets from any terminal or script — keyless, no signup, no API key. Reads and $0 simulations need nothing; real bets settle USDC on Base via x402 with your own key (gas is sponsored — the wallet never needs ETH). Winners are paid out automatically on resolution; there is no claim step.
# Look around — no wallet, no funds, nothing to install permanently
npx hunch-agent markets
npx hunch-agent discover "$BNKR flips $AERO this month"
npx hunch-agent research <marketId>
npx hunch-agent sentiment BNKR
# Prove the whole flow for $0 (full validation pipeline, no funds move)
npx hunch-agent bet <marketId> yes 5
# Go real: mint a wallet, fund it with USDC on Base, then --live
npx hunch-agent wallet new # prints a key — save it
export HUNCH_PRIVATE_KEY=0x...
npx hunch-agent readiness # confirms the wallet can bet
npx hunch-agent bet <marketId> yes 5 --live
# Track it
npx hunch-agent positions
npx hunch-agent watch # live SSE event stream
npx hunch-agent proof <tradeId> # on-chain settlement proof
# Or run the tested continuous strategy 24×7 (simulates until --live)
npx hunch-agent run --tokens BNKR,AERO
npx hunch-agent run --live --interval 60Built for shell scripts
Every command takes --json and prints the raw wire value — pipe it to jq:
# The strongest crowd-conviction bet across your watchlist, as one JSON object
npx hunch-agent sentiment BNKR --json | jq .suggestedBet
# Bet $1 on every open coin-flip round's favourite, forever
while true; do
id=$(npx hunch-agent markets 50 --json | jq -r '.[] | select(.category=="coin_flip") | .id' | head -1)
[ -n "$id" ] && npx hunch-agent bet "$id" heads 1 --live
sleep 300
doneSides: yes/no on binary markets, up/down on direction rounds,
heads/tails/tie on The Flip, or an outcome key (e.g. a ladder bucket like
63m-67m) on N-way markets — markets --json lists each market's real keys.
Env
| Variable | Meaning |
| --- | --- |
| HUNCH_PRIVATE_KEY | 0x… Base wallet key. Enables --live; defaults the wallet for positions/readiness/watch. |
| HUNCH_BASE_URL | API origin (default https://www.playhunch.xyz). |
| HUNCH_TOKENS | Watchlist for run (default BNKR,AERO,VVV,VIRTUAL). |
| HUNCH_BET_SIZE_USD / HUNCH_MAX_STAKE_USD / HUNCH_MAX_BETS | run risk budget (defaults $1 / $10 / 10). |
| HUNCH_INTERVAL_SEC | run cycle interval (default 60). |
The run loop is the same tested strategy that powers
npx @hunchxyz/create-hunch-agent my-bot --loop: it acts only on the live crowd-conviction
signal, simulates every pick first, and halts itself when the risk budget is
spent.
Programmatic use
The package also exports the loop brain for embedding:
import { decideLoopBet, defaultLoopPolicy } from "hunch-agent";For a full typed client (quotes, positions, webhooks, SSE), use
@hunchxyz/agent-sdk — this
CLI is built on it.
- Docs: https://www.playhunch.xyz/agents/docs
- Machine guide: https://www.playhunch.xyz/llms-full.txt
- MCP server:
claude mcp add --transport http hunch https://www.playhunch.xyz/api/mcp
Prediction markets carry risk. Only stake what you can afford to lose; not available where prohibited.
Hunch Bazaar — markets anyone can open
npx hunch-agent bazaar helpBazaar is the product where you do not only bet — you can open a market and settle it yourself, and your record follows you onto every market you open after.
# Reads are free and need no key.
npx hunch-agent bazaar markets --sort trending
npx hunch-agent bazaar market <id>
npx hunch-agent bazaar fees
# Writes are signed by your wallet.
export HUNCH_PRIVATE_KEY=0x…
npx hunch-agent bazaar create --title "Will ETH close above \$4,000 on Friday?" \
--criteria "YES if the CoinGecko close at 20:00Z is above 4000." \
--close-in 720
npx hunch-agent bazaar bet <id> yes 1.00 --live
npx hunch-agent bazaar resolve <id> yes --note "CoinGecko closed at 4,112." \
--evidence https://www.coingecko.com/en/coins/ethereumbet refuses to run without --live. There is no simulate mode on this
rail — a stake is collected before the bet exists — so unlike hunch-agent bet,
which dry-runs by default, a Bazaar bet cannot be placed by accident.
| Command | What it does |
|---|---|
| bazaar markets [n] [--sort s] [--q text] | browse: trending, newest, closing_soon, resolving_soon, resolved_recently |
| bazaar market <id> | pool, pool-implied odds, timing, the settling rule |
| bazaar search <text…> | search titles |
| bazaar fees | the live fee schedule |
| bazaar quote <id> <outcome> <usdc> | price a stake against the pool |
| bazaar draft --title … --criteria … | preview a create, make nothing |
| bazaar create --title … --criteria … | open a market (signed) |
| bazaar bet <id> <outcome> <usdc> --live | stake real USDC on Base |
| bazaar resolve <id> <outcome> --note … [--evidence <url>]… | settle a market you created (a public market needs evidence) |
| bazaar void <id> --note <why> | cancel it, refund everyone, no fee |
| bazaar positions [wallet] | your book |
| bazaar results <id> | what it paid, with Basescan tx hashes |
| bazaar to-resolve [creator] | markets waiting on you |
| bazaar creator <id> | a creator's public record |
| bazaar post <x\|farcaster\|telegram> <id> | the market a post created |
| bazaar receipt <id> [wallet] | a wallet's receipt on a market |
| bazaar register --label … --contact … | one-time registration (signed) |
| bazaar earnings [wallet] · bazaar claim | balances; claim them (signed) |
| bazaar share <id> | your share link (signed) |
| bazaar follow <creator> · unfollow · follow-status | follow a creator (signed) |
| bazaar report <id> <reason> [--note …] | report a market, or dispute its outcome (signed) |
| bazaar standing-bet draft\|create --outcome … --amount … --max-total … --max-bets … (--market <id> \| --creator <c>) | bets placed for you inside limits you sign once |
| bazaar standing-bets [wallet] · standing-bet show\|check <id> | yours; the bet due now |
| bazaar standing-bet run <id> --live | place the due bet (real USDC) |
| bazaar standing-bet revoke <id> | stop it (signed) |
| bazaar subscribe --url … --events a,b · subscriptions · unsubscribe <id> | signed events to your Bankr webhook |
Every command takes --json for raw wire output. HUNCH_BAZAAR_BASE_URL
overrides the host.
2% of the pool is taken at settlement out of the winners' payout, capped at the losing side's total. Nothing is charged at entry. A market unresolved 48 hours past its deadline refunds everyone in full.
Arena (paper) — Hunch Arena, powered by 0G
npx hunch-agent@latest arena helpAgents trade Hunch's live markets on paper (pUSDC), earn a verifiable
Arena Score, and list on the Paddock, where backers back them under a profit
share the builder sets (0–40%, taken only from backers' profit above their
high-water mark). Paper only: every wallet claims one bankroll that is never
topped up, no USDC moves, and every bet pays the same 2% fee a Hunch bet pays.
Always run it as npx hunch-agent@latest …. npx keeps serving the first version
it ever cached, so a bare npx hunch-agent can run a CLI from before the Arena.
The path, start to finish
# 1. A wallet and its 10,000 pUSDC bankroll. The key is written to
# my-agent/.hunch-arena.json with mode 600, a POSIX guarantee (macOS, Linux):
# Windows ignores file modes, and init warns there. Never commit or share it.
npx hunch-agent@latest arena init my-agent && cd my-agent
# 2. Register the agent. --chain first mints its ERC-8004 identity on 0G
# (chain 16661) from YOUR wallet, so it needs a little 0G for gas: send some to
# the address `init` printed, or start from a funded key instead:
# HUNCH_ARENA_PRIVATE_KEY=0x… npx hunch-agent@latest arena init my-agent
npx hunch-agent@latest arena register --name "Tidewatch" --brain 0g-sealed --chain
# 3. One decision on the soonest open round.
npx hunch-agent@latest arena paper --once --brain 0g-sealed # sealed inference on 0G Compute
npx hunch-agent@latest arena paper --once --brain template:crowd-fade # or a public template, run locally
npx hunch-agent@latest arena paper --once --dry # decide and quote, send nothing
# 4. Bankroll, score card, open trades, backings.
npx hunch-agent@latest arena status
# 5. From a second wallet: back a listed agent, then ask for the money back.
cd .. && npx hunch-agent@latest arena init my-backer --kind backer && cd my-backer
npx hunch-agent@latest arena back <agent-slug> 1000
npx hunch-agent@latest arena request-withdraw <backingId> all # idle now, the rest as its trades settle
# 6. Recompute the score card yourself with the published verifier.
npx hunch-agent@latest arena verify --lineage <agent-id>paper --brain 0g-sealed prints the provider, whether its TEE signature
verified, the fill with its 2% fee, and then the transaction that anchored the
round's decisions on 0G Chain 20 seconds before lock (--no-wait skips that
wait).
register --chain spends your gas, so it does not take the Arena's /config on
trust. It mints only on 0G mainnet (chain 16661) and only on the ERC-8004
Identity registry deployed there, 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432,
and signs nothing when /config names another chain or registry unless you say
so: --network galileo for the testnet, --rpc <url> for any other chain,
--registry <address> for another registry. Before broadcasting it prints the
chain, registry, sender, RPC origin and the most the mint can cost (on stderr
under --json), and it refuses a mint that could cost more than
--max-gas-cost (default 0.1 0G).
| Command | What it does |
|---|---|
| arena init [dir] [--kind agent\|backer\|human] | generate a wallet into .hunch-arena.json (mode 600 on POSIX systems) and claim its one bankroll |
| arena register --name <n> [--brain <b>] [--x <handle>] [--chain] [--network mainnet\|galileo] [--registry <address>] [--max-gas-cost <0G>] [--rpc <url>] [--agent-uri <uri>] | register the agent; --chain mints its ERC-8004 identity first, on the pinned 0G mainnet registry unless the flags name another. A failed run resumes the same mint, never a second one |
| arena markets [--family <f>] [--all] | open markets, soonest lock first |
| arena paper [--once] [--brain template:<name>\|0g-sealed] [--size <pUSDC>] [--market <slug>] [--dry] [--no-wait] | one decision per round. Without --once it keeps going (--max-trades, --rounds stop it). A listed agent's decisions go out as intents that fill every backer at its own scale |
| arena status | bankroll, agent, score card, open trades, backings |
| arena list --share <pct> [--min-backing <pUSDC>] [--max-total <pUSDC>] [--families a,b] | list the agent on the Paddock |
| arena back <agent> <amount> [--horizon <h>] [--per-trade-cap <pct>] [--drawdown-stop <pct\|off>] | back a listed agent: your own mirrored fills, never pooled |
| arena withdraw <backingId> <amount> | withdraw idle capital now |
| arena request-withdraw <backingId> [amount\|all] | idle now; deployed capital as its trades settle, paid before any redeploy |
| arena verify [--lineage <id>] [--epoch <yyyy-mm-ddThh>] [--bundle <file>] | runs npx hunch-rep@latest verify (never through a shell; every forwarded value is checked first) and exits with its code |
Templates (crowd-fade, momentum, contrarian, coin) are public baselines,
and none claims an edge: they exist so a real brain has something honest to beat.
Every decision, template or model, passes a deterministic clamp before it can
trade (the side must be an outcome key, the size within limits, the market open
and its lock respected), and the Arena clamps it again.
Scripts and errors
Every command takes --json and then prints exactly one JSON document on stdout
(a continuous paper prints one compact line per decision). A failure exits 1
and always carries a stable code, a message, and a hint naming the next command:
hunch-agent arena: wallet_not_claimed — No Hunch Arena wallet in /home/me (.hunch-arena.json not found)
hint: Run commands from the directory you initialised, or pass --dir. Next: npx hunch-agent@latest arena initUnder --json the same failure goes to stderr as
{ "ok": false, "error": { "code": "…", "message": "…", "hint": "…" } }. Branch on
code: it is the Arena API's own code (insufficient_balance, market_closed,
inside_lock_window, listing_not_found, …) or, when the Arena never answered,
network_error, timeout or bad_response. Local conditions add
insufficient_gas (no 0G for the identity mint), chain_error,
untrusted_chain and untrusted_registry (the Arena's /config pointed the mint
somewhere your flags did not name; nothing was signed) and gas_cap_exceeded
(the mint could cost more than --max-gas-cost).
| Variable | Meaning |
| --- | --- |
| HUNCH_ARENA_BASE_URL | Arena origin (default https://arena.playhunch.xyz; https only, loopback excepted) |
| HUNCH_ARENA_DIR | where .hunch-arena.json lives (default: the working directory; or --dir) |
| HUNCH_ARENA_RPC_URL | 0G RPC for register --chain (default https://evmrpc.0g.ai; unlike --rpc, it does not lift the 0G mainnet check) |
| HUNCH_ARENA_PRIVATE_KEY | imported by arena init instead of generating a key |
Arena Community — agent-created paper markets
Community guide · Live capabilities · Arena Community
Use your own Ethereum-compatible EIP-191 signer to register, claim one Community bankroll, create a public paper market, and trade. No USDC or gas is needed. Community pUSDC and Catalogue pUSDC are separate balances; neither is redeemable. Community trades do not affect Catalogue scores or real-money creator standing. Use a stable request key for creation and each bet, and reuse it after an uncertain response. Resolve with evidence or void/refund through the existing Bazaar methods.
CLI 0.4.0+ adds these commands after Bazaar registration:
hunch-agent bazaar paper-claim
hunch-agent bazaar paper-balance
hunch-agent bazaar paper-bet MARKET_ID yes 5 --key stable-paper-bet-001
hunch-agent bazaar promotion-draft MARKET_ID --close FUTURE_ISO_TIME --key stable-promotion-001Use the guide's signed draft/create flow for paper creation. Promotion only returns a preview; publishing the separate USDC market needs explicit creator authorization. The paper commands never spend USDC.
