# langchain-egg-verify

LangChain tools for [egg-verify](https://egg-verify.onrender.com), a pay-per-call fact-check and research API. Your agent pays per request in USDC on Base over [x402](https://www.x402.org). There's no account and no API key: a wallet holding a few cents of USDC is the only credential. egg-verify settles only after a successful response, so failed calls are never charged.

Made by **[ScrapeMole](https://scrapemole.pages.dev)**. MIT licensed. Not affiliated with egg-verify.

| Tool | Endpoint | Price | What it returns |
| --- | --- | --- | --- |
| `egg_verify_claim` | `POST /verify` | $0.05 | SUPPORTED / REFUTED / UNCLEAR for a claim against one URL, with verbatim quotes |
| `egg_scout` | `POST /scout` | $0.50 | Extractive summary of up to 3 URLs against a brief |
| `egg_deepdive` | `POST /deepdive` | $2.00 | Cross-source synthesis of up to 8 URLs, with open questions |
| `egg_service_card` | `GET /` | free | Endpoints and prices |

## Install

```bash
git clone https://scrapemole.pages.dev/code/egg-verify-langchain.git
cd egg-verify-langchain
python -m venv .venv && . .venv/bin/activate
pip install -e ".[test]"
python -m pytest -q        # free tests: reads the unpaid 402, pays nothing
```

Requires Python 3.10+. Dependencies: `langchain-core`, `x402[evm]` (Coinbase's x402 SDK), `eth-account`, `requests`.

## Make one paid call ($0.05)

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

It quotes the price from the free 402 first, refuses anything above $0.05, then prints the verdict, the quotes and the Basescan link of the settlement.

## Use in code

```python
from langchain_egg_verify import EggVerifyClient, get_egg_verify_tools

tools = get_egg_verify_tools(EggVerifyClient(max_usdc_per_call="0.05"))
verify = tools[1]
print(verify.invoke({"claim": "x402 uses HTTP 402", "url": "https://www.x402.org/"}))
```

## Spending safety

- `max_usdc_per_call` (default **$0.05**) is enforced twice: by a local price check and by the x402 SDK's `max_amount` policy, before anything is signed. `egg_scout` and `egg_deepdive` refuse to run until you raise the cap on purpose.
- The key is read from `AGENT_PRIVATE_KEY` and only used locally to sign an EIP-3009 authorization. Use a dedicated wallet with a small balance.
- `/verify` verdicts are egg-verify's automated heuristic, so treat `UNCLEAR` as "read the quotes".
