ryocryptoguard 0.2.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.
Files changed (29) hide show
  1. ryocryptoguard-0.2.0/LICENSE +21 -0
  2. ryocryptoguard-0.2.0/MANIFEST.in +7 -0
  3. ryocryptoguard-0.2.0/PKG-INFO +440 -0
  4. ryocryptoguard-0.2.0/README.md +405 -0
  5. ryocryptoguard-0.2.0/assets/banner1.jpg +0 -0
  6. ryocryptoguard-0.2.0/assets/logo.png +0 -0
  7. ryocryptoguard-0.2.0/assets/logo.svg +116 -0
  8. ryocryptoguard-0.2.0/cryptoguard/__init__.py +26 -0
  9. ryocryptoguard-0.2.0/cryptoguard/__main__.py +8 -0
  10. ryocryptoguard-0.2.0/cryptoguard/analyzer.py +1039 -0
  11. ryocryptoguard-0.2.0/cryptoguard/cli.py +424 -0
  12. ryocryptoguard-0.2.0/cryptoguard/constants.py +226 -0
  13. ryocryptoguard-0.2.0/cryptoguard/goplus.py +227 -0
  14. ryocryptoguard-0.2.0/cryptoguard/hook.py +232 -0
  15. ryocryptoguard-0.2.0/cryptoguard/mcp_server.py +334 -0
  16. ryocryptoguard-0.2.0/cryptoguard/py.typed +0 -0
  17. ryocryptoguard-0.2.0/cryptoguard/report.py +387 -0
  18. ryocryptoguard-0.2.0/cryptoguard/reputation.py +347 -0
  19. ryocryptoguard-0.2.0/cryptoguard/ryo.py +120 -0
  20. ryocryptoguard-0.2.0/cryptoguard/scanner.py +286 -0
  21. ryocryptoguard-0.2.0/pyproject.toml +72 -0
  22. ryocryptoguard-0.2.0/ryocryptoguard.egg-info/PKG-INFO +440 -0
  23. ryocryptoguard-0.2.0/ryocryptoguard.egg-info/SOURCES.txt +27 -0
  24. ryocryptoguard-0.2.0/ryocryptoguard.egg-info/dependency_links.txt +1 -0
  25. ryocryptoguard-0.2.0/ryocryptoguard.egg-info/entry_points.txt +3 -0
  26. ryocryptoguard-0.2.0/ryocryptoguard.egg-info/requires.txt +14 -0
  27. ryocryptoguard-0.2.0/ryocryptoguard.egg-info/top_level.txt +1 -0
  28. ryocryptoguard-0.2.0/setup.cfg +4 -0
  29. ryocryptoguard-0.2.0/tests/test_hook.py +113 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 momenbasel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,7 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ recursive-include cryptoguard *.py
5
+ include assets/banner1.jpg
6
+ include assets/logo.svg
7
+ include assets/logo.png
@@ -0,0 +1,440 @@
1
+ Metadata-Version: 2.4
2
+ Name: ryocryptoguard
3
+ Version: 0.2.0
4
+ Summary: AI agent safety layer for crypto transactions - blocks honeypots, blacklists, and rug pulls before they happen
5
+ Author-email: momenbasel <momenbasel@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/momenbasel/CryptoGuard
8
+ Project-URL: Repository, https://github.com/momenbasel/CryptoGuard
9
+ Project-URL: Issues, https://github.com/momenbasel/CryptoGuard/issues
10
+ Keywords: crypto,security,honeypot,blacklist,rug-pull,smart-contract,defi,web3,claude-code,ai-agent,mcp,hook,safety,market-research,ryo
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Security
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests>=2.28.0
24
+ Requires-Dist: click>=8.0.0
25
+ Requires-Dist: rich>=13.0.0
26
+ Provides-Extra: mcp
27
+ Requires-Dist: mcp>=1.0.0; extra == "mcp"
28
+ Provides-Extra: ryo
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest>=7.0; extra == "dev"
31
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
32
+ Requires-Dist: responses>=0.23.0; extra == "dev"
33
+ Requires-Dist: ruff>=0.3.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ <p align="center">
37
+ <img src="assets/banner1.jpg" alt="RyoCryptoGuard Banner" width="100%"/>
38
+ </p>
39
+
40
+ <p align="center">
41
+ <a href="https://pypi.org/project/ryocryptoguard/"><img src="https://img.shields.io/pypi/v/ryocryptoguard?color=00d4ff&style=flat-square" alt="PyPI"/></a>
42
+ <a href="https://github.com/momenbasel/CryptoGuard/blob/main/LICENSE"><img src="https://img.shields.io/github/license/momenbasel/CryptoGuard?color=00d4ff&style=flat-square" alt="License"/></a>
43
+ <a href="https://github.com/momenbasel/CryptoGuard/stargazers"><img src="https://img.shields.io/github/stars/momenbasel/CryptoGuard?color=00d4ff&style=flat-square" alt="Stars"/></a>
44
+ <a href="https://pypi.org/project/ryocryptoguard/"><img src="https://img.shields.io/pypi/pyversions/ryocryptoguard?color=00d4ff&style=flat-square" alt="Python"/></a>
45
+ </p>
46
+
47
+ # RyoCryptoGuard
48
+
49
+ **The complete pre-trade safety layer for AI agents — contract security + live market context.**
50
+
51
+ RyoCryptoGuard is a pre-transaction hook for AI coding agents (Claude Code, Codex, Cursor, etc.)
52
+ that automatically analyzes smart contracts **and** live market conditions before any crypto
53
+ transaction is executed. It detects honeypots, blacklist functions, rug pulls, and scam tokens
54
+ by cross-referencing multiple independent security oracles — and now enriches every analysis
55
+ with real-time technical data from the RYO market research API.
56
+
57
+ ## The Problem
58
+
59
+ AI agents are increasingly used to execute crypto transactions — swapping tokens, interacting
60
+ with DeFi protocols, and managing wallets. But they have no built-in safety layer to detect:
61
+
62
+ - **Honeypot tokens** — You can buy but never sell
63
+ - **Blacklist contracts** — The owner can freeze your funds after you buy
64
+ - **Rug pulls** — Liquidity can be removed instantly
65
+ - **Tax manipulation** — Fees can be changed to 100% after purchase
66
+ - **Airdrop scams** — Malicious tokens sent to bait interaction
67
+ - **Overbought entries** — Buying into a technically exhausted rally (RSI ≥ 80)
68
+
69
+ **RyoCryptoGuard stops these before a single wei leaves your wallet.**
70
+
71
+ ## How It Works
72
+
73
+ ```
74
+ You/AI Agent: "swap 1 ETH for TOKEN_X on Uniswap"
75
+ |
76
+ [CryptoGuard Hook]
77
+ |
78
+ +-----------+-----------+-----------+
79
+ | | | |
80
+ GoPlus API Bytecode Reputation RYO Market
81
+ Security Scanner Aggregator Research
82
+ | | | |
83
+ | +-----------+ | Price, RSI,
84
+ | | honeypot.is| | ATR, Verdict
85
+ | | TokenSniffer| |
86
+ | | De.Fi | |
87
+ | | QuickIntel | |
88
+ | +-----------+ |
89
+ +-----------+-----------+-----------+
90
+ |
91
+ Risk Score: 0-100
92
+ + Market Context
93
+ |
94
+ SAFE -> Allow transaction
95
+ HIGH -> BLOCK transaction
96
+ ```
97
+
98
+ ### Data Sources
99
+
100
+ CryptoGuard queries **6+ independent sources** in parallel:
101
+
102
+ | Source | What it checks |
103
+ |--------|---------------|
104
+ | **GoPlus Security** | Honeypot, blacklist, tax, ownership, holders, liquidity |
105
+ | **Honeypot.is** | Buy/sell simulation on forked chain state |
106
+ | **TokenSniffer** | Automated audit score, similar known scams |
107
+ | **De.Fi Scanner** | DeFi protocol security issues |
108
+ | **QuickIntel** | Multi-chain token intelligence |
109
+ | **Bytecode Scanner** | Dangerous opcodes, blacklist selectors, proxy patterns |
110
+ | **RYO Market API** | Live price, RSI(14), ATR(14), technical verdict *(optional, requires `RYO_MCP_KEY`)* |
111
+
112
+ ### What It Detects
113
+
114
+ | Risk | Description | Severity |
115
+ |------|-------------|----------|
116
+ | Honeypot | Cannot sell tokens after buying | CRITICAL |
117
+ | Blacklist | Owner can freeze any address | CRITICAL |
118
+ | Balance manipulation | Owner can change anyone's balance | CRITICAL |
119
+ | Airdrop scam | Malicious token sent to bait interaction | CRITICAL |
120
+ | Self-destruct | Contract can destroy itself and drain funds | CRITICAL |
121
+ | Per-address tax | Owner can set 100% tax on YOUR address | CRITICAL |
122
+ | Cannot sell all | Trapped partial balance | CRITICAL |
123
+ | Extreme sell tax | >50% sell tax | CRITICAL |
124
+ | Hidden owner | Concealed admin control | HIGH |
125
+ | Unlocked liquidity | LP can be pulled (rug pull) | HIGH |
126
+ | Unverified source | Code not published for audit | HIGH |
127
+ | Whale concentration | Single wallet holds >20% supply | HIGH |
128
+ | Creator honeypot history | Deployer made honeypots before | HIGH |
129
+ | Modifiable tax/slippage | Fees can be changed post-buy | HIGH |
130
+ | Pausable transfers | Owner can halt all trading | HIGH |
131
+ | Proxy contract | Logic can be silently upgraded | MEDIUM |
132
+ | Mintable supply | New tokens can dilute holdings | MEDIUM |
133
+ | Low liquidity | High slippage or unable to sell | MEDIUM |
134
+ | Similar scam tokens | Code matches known scams | HIGH |
135
+ | RSI overbought ≥ 80 | Technically exhausted entry point | LOW |
136
+ | Bearish RYO verdict | RYO deterministic analysis is bearish | LOW |
137
+
138
+ ---
139
+
140
+ ## Quick Start
141
+
142
+ ### Install
143
+
144
+ ```bash
145
+ pip install ryocryptoguard
146
+ ```
147
+
148
+ ### Install the AI Agent Hook (recommended)
149
+
150
+ ```bash
151
+ # Automatically installs the Claude Code pre-transaction hook
152
+ ryocryptoguard install-hook
153
+
154
+ # Or with custom risk threshold
155
+ ryocryptoguard install-hook --threshold CRITICAL # Only block critical risks
156
+ ryocryptoguard install-hook --threshold MEDIUM # Block medium and above
157
+ ```
158
+
159
+ ### One-Line Install
160
+
161
+ ```bash
162
+ pip install ryocryptoguard && ryocryptoguard install-hook
163
+ ```
164
+
165
+ ### Manual Check
166
+
167
+ ```bash
168
+ # Check a token on Ethereum
169
+ ryocryptoguard check 0xdAC17F958D2ee523a2206206994597C13D831ec7 --chain ethereum
170
+
171
+ # Check on BSC
172
+ ryocryptoguard check 0x... --chain bsc
173
+
174
+ # JSON output (for scripts)
175
+ ryocryptoguard check 0x... --chain polygon --output json
176
+
177
+ # Quick check (just risk level, for scripting)
178
+ ryocryptoguard check 0x... -q
179
+ echo $? # 0=safe, 1=medium, 2=high/critical
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Market Research Commands *(requires `RYO_MCP_KEY`)*
185
+
186
+ Set your RYO builder key once:
187
+
188
+ ```bash
189
+ export RYO_MCP_KEY="ryo_mcp_your_private_key"
190
+ ```
191
+
192
+ Then use the new market commands:
193
+
194
+ ```bash
195
+ # Analyze a single token — price, RSI, ATR, market intel
196
+ ryocryptoguard market SOL
197
+
198
+ # Deep analysis — includes catalysts, risks, ATR-based plan, derivatives
199
+ ryocryptoguard market SOL --deep
200
+
201
+ # Compare two to four tokens side-by-side
202
+ ryocryptoguard market SOL AVAX BNB --intent swing
203
+
204
+ # Check 7-day market-wide sentiment shift
205
+ ryocryptoguard sentiment
206
+
207
+ # JSON output for any market command
208
+ ryocryptoguard market SOL --output json
209
+ ryocryptoguard sentiment --output json
210
+ ```
211
+
212
+ When `RYO_MCP_KEY` is set, `check` automatically fetches market context too —
213
+ the terminal report gains a **RYO Market Context** panel showing price, 24h change,
214
+ RSI, and key points. The hook blocking message gains a one-line market headline.
215
+
216
+ ---
217
+
218
+ ## Integration
219
+
220
+ ### Claude Code (Automatic)
221
+
222
+ After `ryocryptoguard install-hook`, every `cast send`, `swap`, `approve`, and other
223
+ transaction commands are automatically intercepted and analyzed.
224
+
225
+ The hook adds this to your `~/.claude/settings.json`:
226
+
227
+ ```json
228
+ {
229
+ "hooks": {
230
+ "PreToolUse": [
231
+ {
232
+ "matcher": "Bash",
233
+ "hook": "python -m cryptoguard.hook"
234
+ }
235
+ ]
236
+ }
237
+ }
238
+ ```
239
+
240
+ ### OpenAI Codex / Other Agents
241
+
242
+ Use CryptoGuard as a pre-exec wrapper:
243
+
244
+ ```bash
245
+ # Wrap any command
246
+ ryocryptoguard check 0xTOKEN_ADDRESS --chain ethereum -q && cast send 0xTOKEN_ADDRESS ...
247
+ ```
248
+
249
+ ### Python API
250
+
251
+ ```python
252
+ from cryptoguard import analyze
253
+
254
+ result = analyze("0xdAC17F958D2ee523a2206206994597C13D831ec7", chain="ethereum")
255
+
256
+ print(f"Risk: {result.risk_level.value} ({result.risk_score}/100)")
257
+ print(f"Safe: {result.is_safe}")
258
+ print(f"Should block: {result.should_block}")
259
+
260
+ for finding in result.findings:
261
+ print(f" [{finding.severity.value}] {finding.title}")
262
+
263
+ # RYO market data (present when RYO_MCP_KEY is set)
264
+ if result.ryo_market:
265
+ print(result.ryo_market["summary"]["headline"])
266
+ ```
267
+
268
+ ### MCP Server
269
+
270
+ Add to your Claude Code MCP config or any MCP-compatible client:
271
+
272
+ ```json
273
+ {
274
+ "mcpServers": {
275
+ "ryocryptoguard": {
276
+ "command": "python",
277
+ "args": ["-m", "cryptoguard.mcp_server"]
278
+ }
279
+ }
280
+ }
281
+ ```
282
+
283
+ **Three tools are exposed:**
284
+
285
+ | Tool | Input | What it does |
286
+ |------|-------|--------------|
287
+ | `cryptoguard_check` | `address`, `chain` | Full contract security analysis |
288
+ | `ryo_market_context` | `symbol`, `deep?` | Live market + technical analysis via RYO |
289
+ | `ryo_compare_tokens` | `symbols`, `intent?` | Compare 2–4 tokens side-by-side via RYO |
290
+
291
+ An AI agent can now do the full pre-trade workflow through one MCP server:
292
+
293
+ ```
294
+ cryptoguard_check("0xABC...") → is the contract safe?
295
+ ryo_market_context("CAKE") → is the market timing sensible?
296
+ ryo_compare_tokens("SOL, AVAX") → which asset looks stronger?
297
+ ```
298
+
299
+ #### Remote RYO MCP (direct)
300
+
301
+ If you prefer to call RYO's own MCP endpoint directly from a client:
302
+
303
+ ```json
304
+ {
305
+ "mcpServers": {
306
+ "ryo": {
307
+ "url": "https://app-ryochan.com/api/mcp",
308
+ "headers": { "Authorization": "Bearer ${RYO_MCP_KEY}" }
309
+ }
310
+ }
311
+ }
312
+ ```
313
+
314
+ ---
315
+
316
+ ## Configuration
317
+
318
+ ### Environment Variables
319
+
320
+ | Variable | Description | Default |
321
+ |----------|-------------|---------|
322
+ | `CRYPTOGUARD_DISABLE` | Set to `1` to bypass the hook | `0` |
323
+ | `CRYPTOGUARD_CHAIN` | Default chain if not detected | `ethereum` |
324
+ | `CRYPTOGUARD_THRESHOLD` | Min risk level to block (`CRITICAL`, `HIGH`, `MEDIUM`) | `HIGH` |
325
+ | `RYO_MCP_KEY` | RYO builder API key — enables market research commands and automatic market enrichment | *(unset)* |
326
+ | `RYO_MCP_URL` | RYO endpoint override | `https://app-ryochan.com/api/mcp` |
327
+
328
+ Copy `.env.example` to `.env` and fill in your values. **Never commit a populated `.env`.**
329
+
330
+ ### Supported Chains
331
+
332
+ Ethereum, BSC, Polygon, Arbitrum, Base, Optimism, Avalanche, Fantom, zkSync Era, Linea, Scroll, Mantle, Blast
333
+
334
+ ---
335
+
336
+ ## Architecture
337
+
338
+ ```
339
+ cryptoguard/ # Python package (pip install ryocryptoguard)
340
+ __init__.py # Public API
341
+ cli.py # Click CLI (ryocryptoguard / cryptoguard commands)
342
+ hook.py # AI agent pre-transaction hook
343
+ analyzer.py # Core analysis engine + risk scoring
344
+ scanner.py # EVM bytecode pattern analysis
345
+ goplus.py # GoPlus Security API client
346
+ reputation.py # Multi-source reputation aggregator
347
+ ryo.py # RYO market research REST client (NEW in v0.2)
348
+ report.py # Terminal report formatter (Rich)
349
+ mcp_server.py # MCP server for tool-based integration
350
+ constants.py # Chains, selectors, weights
351
+ ```
352
+
353
+ ### Risk Scoring
354
+
355
+ Risk score is 0–100, computed from weighted findings with diminishing returns within categories:
356
+
357
+ | Score | Level | Action |
358
+ |-------|-------|--------|
359
+ | 70–100 | CRITICAL | Block transaction, show full report |
360
+ | 50–69 | HIGH | Block transaction, show findings |
361
+ | 30–49 | MEDIUM | Warn, allow with caution |
362
+ | 15–29 | LOW | Info only |
363
+ | 0–14 | SAFE | Allow silently |
364
+
365
+ RYO market findings are capped at LOW severity — they **never** change the BLOCK decision.
366
+ Market context is informational enrichment only.
367
+
368
+ ---
369
+
370
+ ## Development
371
+
372
+ ```bash
373
+ git clone https://github.com/momenbasel/CryptoGuard.git
374
+ cd CryptoGuard
375
+ pip install -e ".[dev]"
376
+
377
+ # Run tests
378
+ pytest
379
+
380
+ # Lint
381
+ python -m ruff check cryptoguard/
382
+
383
+ # Build distribution
384
+ pip install build
385
+ python -m build
386
+
387
+ # Upload to PyPI
388
+ pip install twine
389
+ twine upload dist/*
390
+ ```
391
+
392
+ ---
393
+
394
+ ## FAQ
395
+
396
+ **Does this slow down my transactions?**
397
+ Analysis takes 2–5 seconds (parallel API calls). Market enrichment runs in the same
398
+ parallel pool — it adds no extra wall-clock time when `RYO_MCP_KEY` is set.
399
+
400
+ **Does it need API keys?**
401
+ No keys required for the safety layer. GoPlus, Honeypot.is, TokenSniffer, De.Fi, and
402
+ QuickIntel all have free public tiers. `RYO_MCP_KEY` is only needed for market research commands.
403
+
404
+ **Can it detect all scams?**
405
+ No tool can guarantee 100% detection. CryptoGuard significantly reduces risk by
406
+ cross-referencing multiple independent sources, but novel scam techniques may bypass
407
+ detection. Always DYOR.
408
+
409
+ **Does it work with hardware wallets?**
410
+ CryptoGuard analyzes the contract, not the wallet. It works regardless of how you sign
411
+ transactions.
412
+
413
+ **Can I use it without an AI agent?**
414
+ Yes. The CLI works standalone:
415
+ ```bash
416
+ ryocryptoguard check 0x... --chain ethereum
417
+ ryocryptoguard market SOL
418
+ ```
419
+
420
+ **Does RYO market data affect the BLOCK decision?**
421
+ No. RYO findings are LOW/INFO severity only. The blocking threshold is driven
422
+ entirely by contract security findings. This boundary is intentional and will not change.
423
+
424
+ ---
425
+
426
+ ## License
427
+
428
+ MIT
429
+
430
+ ## Credits
431
+
432
+ Built by [@momenbasel](https://github.com/momenbasel).
433
+ Security data powered by GoPlus, Honeypot.is, TokenSniffer, De.Fi, and QuickIntel.
434
+ Market research powered by [RYO](https://app-ryochan.com).
435
+
436
+ PyPI: [pypi.org/project/ryocryptoguard](https://pypi.org/project/ryocryptoguard/)
437
+
438
+ ---
439
+
440
+ **If this tool saves you from a scam, star the repo and share it. Every star helps protect more people.**