Skip to main content

Python client for the Hunch agent platform — keyless, no-cap x402 prediction-market betting on Base.

Project description

hunch-agent (Python)

Python client for the Hunch agent platform. Keyless, no-cap, auto-payout.

# PyPI release pending — install from source:
pip install "git+https://github.com/rajkaria/hunch.git#subdirectory=sdk/python"
# or from a local clone:  pip install -e sdk/python

$0 simulation (no wallet)

from hunch_agent import HunchAgent

hunch = HunchAgent()  # defaults to https://www.playhunch.xyz
markets = hunch.markets(status="open", limit=5)
research = hunch.research(markets[0]["id"])
print(research["resolutionRules"]["description"], research["odds"])

sim = hunch.bet(
    markets[0]["id"], "yes", 1,
    wallet_address="0xYourWallet...", simulate=True,
)
print(sim["simulated"], sim["position"])  # True, {...}

Real bet (x402 USDC on Base)

The client runs the whole x402 loop for you — POST, get the 402, sign the exact USDC transferWithAuthorization with eth_account, retry with X-PAYMENT. The wallet only needs USDC on Base; gas is sponsored. Winners are paid automatically — no claim step.

from eth_account import Account
from hunch_agent import HunchAgent

account = Account.from_key("0x...")             # a funded Base wallet
hunch = HunchAgent(account=account)

receipt = hunch.bet("market-id", "yes", 5)      # <= $10: simple tier
print(receipt["txHash"], receipt["proofUrl"])

# > $10: lock a quote first.
q = hunch.quote("market-id", "yes", 250)
hunch.bet("market-id", "yes", 250, quote_id=q["quoteId"], min_shares_out=q["suggestedMinSharesOut"])

Verifying webhooks

from hunch_agent import verify_webhook

result = verify_webhook(request.headers, raw_body, secret)
if result["valid"]:
    handle(result["event"])

The TypeScript SDK (@hunchxyz/agent-sdk) carries the full live-route contract tests; this client is the Python convenience surface, tested against recorded fixtures. Full protocol docs: https://www.playhunch.xyz/llms-full.txt.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hunch_agent-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hunch_agent-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file hunch_agent-0.1.0.tar.gz.

File metadata

  • Download URL: hunch_agent-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for hunch_agent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b7990aecadff51260e9c5b76ad94f1c0b69bf5c253c077bd2d6f8afd7935a4b0
MD5 a3ef287aa4ad329cb7df9c5103423841
BLAKE2b-256 9ba6d67d48f6cb6071fd9c7f0cd1b0c01d18c451ba0eae4ce5fec81eada8d140

See more details on using hashes here.

File details

Details for the file hunch_agent-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hunch_agent-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for hunch_agent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be896789618a4f12c74701ec147273f8d90f85522a0d4743c7df62600f3c28ae
MD5 fcc7670d2db148354cb8cece98c2bb9d
BLAKE2b-256 f71f4b63049ad2c4d692fa93aebf3e3c3c6c31b450a25fa196a0c7cfd0e7a1e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page