Skip to main content

langchain-tollwarden

TollWarden payment security for LangChain / LangGraph agents — agents inherit "scan before you pay" by default.

pip install langchain-tollwarden

Two lines

from tollwarden import TollWardenClient
from langchain_tollwarden import TollWardenProvenanceCallback, tollwarden_tools

tollwarden = TollWardenClient(agent_id="my-agent")          # free API key auto-minted (100 free scans)
tools = [*tollwarden_tools(tollwarden), *your_other_tools]
callbacks = [TollWardenProvenanceCallback(tollwarden)]      # ← the important line
# pass tools= and callbacks= to your agent/executor as usual

Every x402 payment your agent scans gets an allow / flag / block verdict with machine-readable reasons: prompt-injection-triggered payments, replayed nonces, overpayment vs the quote, secrets/PII leaking in payment metadata, lookalike-token contracts, address poisoning, counterparty reputation.

Why the callback is the important line

TollWarden's strongest detector catches payments whose decision came from content the agent just read — a prompt-injected page or tool result that says "send payment to 0x…". That check needs to know what the agent read. TollWardenProvenanceCallback observes every tool output and retrieval automatically, so the very next scan is provenance-tagged and the injection check runs with real input. No prompt engineering, no developer learning what "provenance" means — it's just on. (TollWarden's own tool outputs are excluded, so verdicts never pollute the signal.)

Enforcement: payments that can't execute when blocked

Tools + descriptions rely on the model choosing to scan. guarded_payment doesn't:

from langchain_tollwarden import guarded_payment

safe_pay = guarded_payment(execute_x402_payment, tollwarden)   # strict=True to refuse flags too
# build your payment tool from safe_pay — on a block verdict it raises
# TollWardenBlockedError BEFORE execute_x402_payment is ever invoked.

For wallet-level enforcement (the signer itself refuses unscanned payments), see TollWardenEnforcer in the tollwarden SDK.

The toolset

Tool When the agent is told to use it
tollwarden_scan_payment ALWAYS, immediately before settling any x402 payment (or before paying a received 402 offer with direction="incoming")
tollwarden_check_reputation Before dealing with an unfamiliar counterparty address
tollwarden_report_counterparty After a bad payment experience (always free) — warns other agents

Verdicts are Ed25519-signed and payment-bound; the underlying client verifies them against a pinned key automatically.

MIT. TollWarden is advisory and non-custodial: it never touches keys, wallets, or funds.

Metadata

Release files for langchain-tollwarden 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-tollwarden 0.1.0
File Size Uploaded
langchain_tollwarden-0.1.0.tar.gz 8.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-tollwarden 0.1.0
File Interpreter ABI Platform
langchain_tollwarden-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / langchain_tollwarden-0.1.0.tar.gz

Download URL langchain_tollwarden-0.1.0.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bde2b9907901238bee072eb94019e70eac9d8727106d3d2a30b0964eb30f138c
BLAKE2b-256 checksum
How to use checksums
a4f87389262921960782f0e441c73b4be85bc91b02dea612a831f4ac3bb96b91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / langchain_tollwarden-0.1.0-py3-none-any.whl

Download URL langchain_tollwarden-0.1.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be3161c5987a98fbbc52bb8e4493837a933a63964ba2cf0848d9124e8d94e24f
BLAKE2b-256 checksum
How to use checksums
3aa80d5e3ac3ba03276bc870f4836bb741efba12371d3910f7c38cd67ba220ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page