x402 Safe Trading Agent ๐ก๏ธ
March 30, 2026 ยท View on GitHub
An autonomous crypto trading agent that checks token risk before every trade โ powered by Marcus Rug Intel via x402 payments.
No API keys. No subscriptions. Just pay-per-request with USDC on Base or Solana.
What This Does
Agent sees token opportunity
โ
Pays \$0.04 USDC via x402 โ Marcus Rug Intel risk check
โ
Risk score 85+ โ SKIP (saved from rug pull)
Risk score < 40 โ TRADE (with confidence)
Risk score 40-85 โ Deep analysis (\$0.50) โ decide
This is a reference implementation showing how any AI trading agent can integrate on-chain risk intelligence using the x402 payment protocol. Fork it, adapt it, ship it.
Why x402?
Traditional API integration requires: API keys, account creation, billing setup, rate limit management.
With x402: hit the endpoint, pay per request, get data. Your agent handles everything autonomously.
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Safe Trading Agent โ
โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ Discovery โโโ Risk Gate โโโ Trade Decision โ โ
โ โ (Bazaar) โ โ (x402) โ โ (LLM or rule) โ โ
โ โโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ โ โ โ
โ Find services Pay & check Buy / Skip / Deep โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
CDP Bazaar Marcus Rug Intel
(discovery) (cryptorugmunch.app)
Quick Start
Prerequisites
- Python 3.10+
- A wallet with USDC on Base (even $1 is enough for ~25 risk checks)
Install
git clone https://github.com/CryptoRugMunch/x402-trading-agent.git
cd x402-trading-agent
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your wallet private key
Run
# Check a single token before trading
python agent.py check So11111111111111111111111111111111111111112
# Run the autonomous trading loop (watches for new tokens, checks risk, decides)
python agent.py watch --chain solana
# Discover available Marcus Rug Intel endpoints via Bazaar
python agent.py discover
How It Works
1. Discovery (Optional)
The agent can discover Marcus Rug Intel endpoints dynamically via the x402 Bazaar:
from x402_client import discover_services
services = discover_services(category="crypto-security")
# Returns: check-risk, holder-deepdive, marcus-quick, etc.
2. Risk Check (x402 Payment)
Every token check costs $0.04 USDC, paid automatically:
from x402_client import check_risk
result = check_risk("7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr")
# Returns: {risk_score: 85, recommendation: "AVOID", risk_factors: [...]}
3. Trade Decision
if result["risk_score"] >= 80:
print("๐จ HIGH RISK โ skipping")
elif result["risk_score"] >= 40:
# Get deeper analysis for borderline cases
deep = marcus_forensics(token_address)
decide_from_analysis(deep)
else:
print("โ
LOW RISK โ proceeding with trade")
execute_trade(token_address, amount)
Available Endpoints
| Endpoint | Price | Description |
|---|---|---|
check-risk | $0.04 | Risk score (0-100), honeypot detection, recommendation |
check-batch | $0.30 | Batch scan up to 20 tokens |
holder-deepdive | $0.10 | Sniper detection, bundle analysis, whale tracking |
deployer | $0.06 | Deployer history, serial rugger detection |
token-intel | $0.06 | Full token intelligence (price, volume, LP lock) |
marcus-quick | $0.15 | AI forensic verdict (Claude Sonnet 4) |
marcus-forensics | $0.50 | Full AI investigation |
marcus-ultra | $2.00 | Deep analysis (Claude Opus 4) |
watch | $0.20 | 7-day webhook monitoring for risk changes |
Configuration
# .env
WALLET_PRIVATE_KEY=0x... # Your wallet private key (Base USDC)
RISK_THRESHOLD=70 # Skip tokens above this score
DEEP_ANALYSIS_THRESHOLD=40 # Trigger deep analysis for scores 40-70
MAX_SPEND_PER_CHECK=0.50 # Max USDC per individual check
CHAIN=solana # Default chain
MRI_API_URL=https://cryptorugmunch.app # API base URL
Cost Estimates
| Strategy | Checks/Day | Daily Cost |
|---|---|---|
| Conservative (scan before every trade) | 50 | $2.00 |
| Active trader (scan + deep on flags) | 200 | $10-15 |
| Portfolio monitor (batch + watch) | 10 batches | $3.00 + $2.00 watches |
Compare: One rug pull can cost $1K-$100K+. Risk checking costs pennies.
Extending
- Add your own trading logic in
strategies/ - Swap the LLM โ use Marcus AI tiers or bring your own
- Multi-chain โ works with Solana, Ethereum, Base, Arbitrum, Polygon, Optimism, Avalanche
- Webhook alerts โ use the
watchendpoint for passive monitoring
Links
โ ๏ธ Note: This project was formerly known as CryptoRugMunch. The $CRM token is not affiliated with Marcus Rug Intel.
License
MIT โ use it however you want. If it saves you from a rug pull, consider it a win.
Built by Marcus Rug Intel โ the only AI-powered crypto risk intelligence on x402.