LangChain tool: scan Base contracts via BaseSentinel (HTTP 402 + USDC tx-hash proof).
Project description
LangChain tool for BaseSentinel
Python / LangChain integration that lets an agent scan Base contracts via BaseSentinel.
Payment is M2M under the hood (USDC transfer on Base → X-Payment-Proof). The LLM only sees a short risk summary (or a machine-readable BASESENTINEL_ERROR … line on failure — the agent loop does not crash).
Gemini note (corrected here): HTTP 402 means
PAYMENT_REQUIREDonly. Codes likeTX_HASH_CONSUMED/INSUFFICIENT_USDCarrive on other statuses — we branch onerror_code. We wait for a successful receipt before calling/scan. API field isreasons[], notreason.
Install
pip install basesentinel-langchain
# optional ReAct example deps:
pip install "basesentinel-langchain[agents]"
From this repo (editable):
cd packages/langchain-basesentinel
python -m pip install -e .
Tool
from basesentinel_langchain import BaseSentinelScanTool
tool = BaseSentinelScanTool(
private_key="0xYOUR_BASE_WALLET_KEY", # or set BASESENTINEL_PRIVATE_KEY
)
print(tool.invoke({"contract_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}))
# -> Contract 0x… is SAFE (CLEAR). Score: 100/100. Reasons: …
Runtime secrets
| Env | Required | Purpose |
|---|---|---|
BASESENTINEL_PRIVATE_KEY |
yes* | Base wallet key with USDC |
BASESENTINEL_PAYMENT_PROOF |
no | Existing tx hash — skips the spend |
BASESENTINEL_RPC_URL |
no | Default https://mainnet.base.org |
BASESENTINEL_API_BASE_URL |
no | Default https://api.blackswanlabs.pl |
*Required unless BASESENTINEL_PAYMENT_PROOF is set.
Cost per scan: 0.005 USDC → treasury 0x21360A04853b85a8d2E918b73f97C8ccf5939946.
Errors (agent-safe)
On failure the tool returns a string like:
BASESENTINEL_ERROR error_code=INSUFFICIENT_USDC http_status=422 message=...
Stable codes match the API: PAYMENT_REQUIRED, TX_HASH_CONSUMED, TX_HASH_BOUND_OTHER, INSUFFICIENT_USDC, PAYMENT_INVALID, …
ReAct example
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basesentinel_langchain-1.0.0.tar.gz.
File metadata
- Download URL: basesentinel_langchain-1.0.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c37123052f3d580ceedcc41d84b280df61f76b432c369705a5826a2e970058f
|
|
| MD5 |
ced98900191c017706142102589d814b
|
|
| BLAKE2b-256 |
1a487de7b9316c3fecb5e6518cb7787886f6f38049d4cfb6f5af498a2fc468e4
|
File details
Details for the file basesentinel_langchain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: basesentinel_langchain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d530a72d622e3eab4dc0a8cba89acbd173ed84655936ce393234f081c29b957
|
|
| MD5 |
3bf882f24d4c6f81773378243234a755
|
|
| BLAKE2b-256 |
55459cfca1f87a48fc4624e484f2dd43d60304b6237b742cba495bb69e8c6818
|