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
Metadata
Release files for basesentinel-langchain 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| basesentinel_langchain-1.0.0.tar.gz | 9.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| basesentinel_langchain-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.0 kB
Release files / basesentinel_langchain-1.0.0.tar.gz
| Download URL | basesentinel_langchain-1.0.0.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c37123052f3d580ceedcc41d84b280df61f76b432c369705a5826a2e970058f
|
|
BLAKE2b-256 checksum How to use checksums |
1a487de7b9316c3fecb5e6518cb7787886f6f38049d4cfb6f5af498a2fc468e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / basesentinel_langchain-1.0.0-py3-none-any.whl
| Download URL | basesentinel_langchain-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7d530a72d622e3eab4dc0a8cba89acbd173ed84655936ce393234f081c29b957
|
|
BLAKE2b-256 checksum How to use checksums |
55459cfca1f87a48fc4624e484f2dd43d60304b6237b742cba495bb69e8c6818
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|