"""Make one real paid /verify call ($0.05) through the LangChain tool and print the proof.

    export AGENT_PRIVATE_KEY=0x...   # a dedicated Base wallet holding >= $0.05 USDC; no ETH needed
    python examples/paid_call.py

The per-call cap is $0.05, so any higher quote is refused before anything is signed.
"""

import json

from langchain_egg_verify import EggVerifyClaimTool, EggVerifyClient

client = EggVerifyClient(max_usdc_per_call="0.05")
opt = client.quote("verify", {"claim": "x", "url": "https://example.com"})  # free
print(f"quoted /verify: {int(opt['amount']) / 1e6:.2f} USDC to {opt['payTo']}")
if int(opt["amount"]) > 50_000:
    raise SystemExit("quote above $0.05, refusing to pay")

tool = EggVerifyClaimTool(client=client)
out = json.loads(tool.invoke({
    "claim": "The x402 protocol uses the HTTP 402 Payment Required status code.",
    "url": "https://www.x402.org/",
}))
r = out["result"]
print("verdict:", r.get("verdict"), "| confidence:", r.get("confidence"))
for q in (r.get("evidence") or [])[:3]:
    print("  >", q[:160])
pay = out.get("payment", {})
print("payer:", pay.get("payer"))
print("transaction:", pay.get("transaction"))
if pay.get("transaction"):
    print(f"https://basescan.org/tx/{pay['transaction']}")
