langchain-x402bazaar 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ node_modules/
2
+ dist/
3
+ __pycache__/
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ *.tgz
8
+ .venv/
9
+ .eliza-probe/
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.5
2
+ Name: langchain-x402bazaar
3
+ Version: 0.1.0
4
+ Summary: LangChain tool for x402 Bazaar — pre-trade token-verdict (SAFE/CAUTION/AVOID) for any Base token, paid per call over x402.
5
+ Project-URL: Homepage, https://402.com.tr
6
+ Project-URL: Repository, https://github.com/sukrutkrdg/x402-bazaar-plugins
7
+ Author-email: x402 Bazaar <sukrutkrdg@gmail.com>
8
+ License: MIT
9
+ Keywords: ai-agents,base,honeypot,langchain,rug,token-safety,token-verdict,usdc,x402
10
+ Requires-Python: >=3.9
11
+ Requires-Dist: langchain-core>=0.3.0
12
+ Requires-Dist: pydantic>=2.0.0
13
+ Requires-Dist: requests>=2.31.0
14
+ Provides-Extra: pay
15
+ Requires-Dist: eth-account>=0.11.0; extra == 'pay'
16
+ Requires-Dist: x402>=0.1.0; extra == 'pay'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # langchain-x402bazaar
20
+
21
+ A [LangChain](https://python.langchain.com) tool for [x402 Bazaar](https://402.com.tr) —
22
+ a **pre-trade token safety verdict** for any Base ERC-20, for AI agents.
23
+
24
+ `token_verdict` returns one **SAFE / CAUTION / AVOID / UNKNOWN** answer with the
25
+ reasons behind it and a recommended max position size, distilling the full
26
+ pre-trade stack (honeypot, sell-tax, owner powers, exit-liquidity, deployer, B20
27
+ seize/freeze). Paid per call over [x402](https://x402.org) ($0.03 USDC on Base),
28
+ or **1 free call/day per IP** — no wallet needed to start.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pip install langchain-x402bazaar
34
+ # optional, to pay per call with your own wallet instead of the free tier:
35
+ pip install "langchain-x402bazaar[pay]"
36
+ ```
37
+
38
+ ## Use
39
+
40
+ ```python
41
+ from langchain_x402bazaar import token_verdict
42
+
43
+ # Works with no wallet (free daily call):
44
+ print(token_verdict.invoke({"address": "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed"}))
45
+
46
+ # In an agent:
47
+ from langchain.agents import create_tool_calling_agent
48
+ agent = create_tool_calling_agent(llm, [token_verdict, ...], prompt)
49
+ ```
50
+
51
+ ### Paying per call
52
+
53
+ Set a funded EVM wallet (USDC on Base) and install the `pay` extra:
54
+
55
+ ```bash
56
+ export X402_EVM_PRIVATE_KEY=0x...
57
+ ```
58
+
59
+ When present, each call pays $0.03 USDC over x402; otherwise the tool uses the
60
+ free daily call.
61
+
62
+ ## Output
63
+
64
+ ```json
65
+ {
66
+ "address": "0x4ed4…efed",
67
+ "verdict": "CAUTION",
68
+ "confidence": "high",
69
+ "headline": "Tradeable, but with real risks — size down and stay exit-ready.",
70
+ "reasons": ["[owner-powers] mutable owner controls remain: is_mintable", "…"],
71
+ "recommendedMaxSizeUsd": 3992,
72
+ "cardUrl": "https://402.com.tr/brand/verdict?v=CAUTION&…"
73
+ }
74
+ ```
75
+
76
+ Part of [x402 Bazaar](https://402.com.tr) — 230+ pay-per-call APIs for AI agents on Base + NEAR. MIT licensed.
@@ -0,0 +1,58 @@
1
+ # langchain-x402bazaar
2
+
3
+ A [LangChain](https://python.langchain.com) tool for [x402 Bazaar](https://402.com.tr) —
4
+ a **pre-trade token safety verdict** for any Base ERC-20, for AI agents.
5
+
6
+ `token_verdict` returns one **SAFE / CAUTION / AVOID / UNKNOWN** answer with the
7
+ reasons behind it and a recommended max position size, distilling the full
8
+ pre-trade stack (honeypot, sell-tax, owner powers, exit-liquidity, deployer, B20
9
+ seize/freeze). Paid per call over [x402](https://x402.org) ($0.03 USDC on Base),
10
+ or **1 free call/day per IP** — no wallet needed to start.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ pip install langchain-x402bazaar
16
+ # optional, to pay per call with your own wallet instead of the free tier:
17
+ pip install "langchain-x402bazaar[pay]"
18
+ ```
19
+
20
+ ## Use
21
+
22
+ ```python
23
+ from langchain_x402bazaar import token_verdict
24
+
25
+ # Works with no wallet (free daily call):
26
+ print(token_verdict.invoke({"address": "0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed"}))
27
+
28
+ # In an agent:
29
+ from langchain.agents import create_tool_calling_agent
30
+ agent = create_tool_calling_agent(llm, [token_verdict, ...], prompt)
31
+ ```
32
+
33
+ ### Paying per call
34
+
35
+ Set a funded EVM wallet (USDC on Base) and install the `pay` extra:
36
+
37
+ ```bash
38
+ export X402_EVM_PRIVATE_KEY=0x...
39
+ ```
40
+
41
+ When present, each call pays $0.03 USDC over x402; otherwise the tool uses the
42
+ free daily call.
43
+
44
+ ## Output
45
+
46
+ ```json
47
+ {
48
+ "address": "0x4ed4…efed",
49
+ "verdict": "CAUTION",
50
+ "confidence": "high",
51
+ "headline": "Tradeable, but with real risks — size down and stay exit-ready.",
52
+ "reasons": ["[owner-powers] mutable owner controls remain: is_mintable", "…"],
53
+ "recommendedMaxSizeUsd": 3992,
54
+ "cardUrl": "https://402.com.tr/brand/verdict?v=CAUTION&…"
55
+ }
56
+ ```
57
+
58
+ Part of [x402 Bazaar](https://402.com.tr) — 230+ pay-per-call APIs for AI agents on Base + NEAR. MIT licensed.
@@ -0,0 +1,4 @@
1
+ from .tool import token_verdict, TokenVerdictInput
2
+
3
+ __all__ = ["token_verdict", "TokenVerdictInput"]
4
+ __version__ = "0.1.0"
@@ -0,0 +1,93 @@
1
+ """LangChain tool for x402 Bazaar — token-verdict pre-trade safety check.
2
+
3
+ The tool works with no wallet by default (1 free call/day per IP). When a funded
4
+ EVM wallet is configured (env ``X402_EVM_PRIVATE_KEY`` and the optional ``pay``
5
+ extra installed), it pays $0.03 USDC per call over x402 on Base instead.
6
+ """
7
+
8
+ import os
9
+ from typing import Optional
10
+
11
+ import requests
12
+ from pydantic import BaseModel, Field
13
+ from langchain_core.tools import tool
14
+
15
+ TOKEN_VERDICT_URL = "https://402.com.tr/api/x402/token-verdict"
16
+ BASE_CHAIN = "eip155:8453"
17
+ USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
18
+
19
+
20
+ class TokenVerdictInput(BaseModel):
21
+ address: str = Field(
22
+ ...,
23
+ pattern=r"^0x[a-fA-F0-9]{40}$",
24
+ description="Base ERC-20 token address (0x + 40 hex chars).",
25
+ )
26
+ amount_usd: Optional[float] = Field(
27
+ None,
28
+ description="Intended trade size in USD; tunes the recommended max safe size.",
29
+ )
30
+
31
+
32
+ def _paid_session():
33
+ """Return an x402-paying ``requests`` session if a funded wallet is
34
+ configured (env ``X402_EVM_PRIVATE_KEY`` + the ``pay`` extra installed),
35
+ otherwise ``None`` so the tool falls back to the free daily call.
36
+
37
+ The x402 Python client API has drifted across versions, so this imports
38
+ defensively and returns ``None`` on any import/constructor mismatch — the
39
+ free tier keeps the tool usable regardless.
40
+ """
41
+ pk = os.getenv("X402_EVM_PRIVATE_KEY")
42
+ if not pk:
43
+ return None
44
+ try:
45
+ from eth_account import Account # type: ignore
46
+ from x402.clients import x402Client # type: ignore
47
+ from x402.http.clients import x402_requests # type: ignore
48
+ from x402.mechanisms.evm import EthAccountSigner # type: ignore
49
+ from x402.mechanisms.evm.exact.register import register_exact_evm_client # type: ignore
50
+
51
+ client = x402Client()
52
+ register_exact_evm_client(client, EthAccountSigner(Account.from_key(pk)))
53
+ return x402_requests(client)
54
+ except Exception:
55
+ return None
56
+
57
+
58
+ @tool(args_schema=TokenVerdictInput)
59
+ def token_verdict(address: str, amount_usd: Optional[float] = None) -> dict:
60
+ """Pre-trade safety check for a Base (eip155:8453) ERC-20 token before buying
61
+ or approving it. Returns a SAFE / CAUTION / AVOID / UNKNOWN verdict with
62
+ confidence, the reasons behind it, and a recommended max position size
63
+ (honeypot, sell-tax, owner powers, exit-liquidity, B20 seize/freeze). Powered
64
+ by x402 Bazaar: $0.03 USDC/call over x402, or 1 free call/day per IP."""
65
+ params: dict = {"address": address}
66
+ if amount_usd is not None:
67
+ params["amountUsd"] = amount_usd
68
+
69
+ session = _paid_session()
70
+ try:
71
+ if session is not None:
72
+ with session as s:
73
+ r = s.get(TOKEN_VERDICT_URL, params=params, timeout=40)
74
+ else:
75
+ params["free"] = "1"
76
+ r = requests.get(TOKEN_VERDICT_URL, params=params, timeout=40)
77
+ except Exception as e: # network error
78
+ return {"error": "request_failed", "message": str(e)}
79
+
80
+ if r.status_code == 402:
81
+ return {
82
+ "error": "payment_required",
83
+ "chain": BASE_CHAIN,
84
+ "asset": USDC_BASE,
85
+ "message": (
86
+ "Set X402_EVM_PRIVATE_KEY (funded USDC on Base) and install the "
87
+ "`pay` extra to pay, or omit for the free daily call."
88
+ ),
89
+ }
90
+ r.raise_for_status()
91
+ body = r.json()
92
+ # Free tier wraps the result in {"data": ...}; the paid x402 call returns it raw.
93
+ return body.get("data", body) if isinstance(body, dict) else body
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "langchain-x402bazaar"
7
+ version = "0.1.0"
8
+ description = "LangChain tool for x402 Bazaar — pre-trade token-verdict (SAFE/CAUTION/AVOID) for any Base token, paid per call over x402."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "x402 Bazaar", email = "sukrutkrdg@gmail.com" }]
13
+ keywords = ["x402", "langchain", "base", "token-safety", "honeypot", "rug", "token-verdict", "ai-agents", "usdc"]
14
+ dependencies = ["langchain-core>=0.3.0", "requests>=2.31.0", "pydantic>=2.0.0"]
15
+
16
+ [project.optional-dependencies]
17
+ pay = ["x402>=0.1.0", "eth-account>=0.11.0"]
18
+
19
+ [project.urls]
20
+ Homepage = "https://402.com.tr"
21
+ Repository = "https://github.com/sukrutkrdg/x402-bazaar-plugins"
22
+
23
+ [tool.hatch.build.targets.wheel]
24
+ packages = ["langchain_x402bazaar"]