DIREWOLFE-X/Protocol-Zero
๐ก๏ธ Protocol Zero โ Autonomous ERC-8004 DeFi Trading Agent
   
Capital preservation first, profit second.
Protocol Zero is a trust-minimized, autonomous DeFi trading agent built on the ERC-8004 standard for on-chain agent identity, reputation, and validation. It combines AI-driven market reasoning (Amazon Bedrock Nova) with cryptographic accountability (EIP-712 signed intents) and a multi-layered risk management pipeline.
๐ฌ Demo
๐บ Demo Video โ Coming soon before final submission. Run streamlit run streamlit_app.py to see Protocol Zero live: AI-driven market analysis, EIP-712 intent signing, and on-chain ERC-8004 registration โ all in one cinematic dashboard.๐ธ Screenshots
Run streamlit run streamlit_app.py to experience the full cinematic dashboard: cognitive stream, market regime orb, trade DNA, risk heat-map, XAI reasoning panel, and more. Screenshots will be added before final submission.Architecture
โโโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ
โ Fetch โ โโโบ โ Brain โ โโโบ โ Risk Check โ โโโบ โ Validate + โ
โ Market โ โ (Nova) โ โ (6 checks) โ โ Sign (EIP712) โ
โ Data โ โ โ โ โ โ โ
โโโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโฌโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โผ โผ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโ
โ Validation โ โ Reputation โ
โ Artifacts โ โ (giveFeedback) โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโCore Modules
Nova AI Integrations
Quick Start
1. Clone & Install
git clone https://github.com/Direwolfe999/Protocol-Zero.git
cd Protocol-Zero
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt2. Configure Environment
cp .env.example .env
# Edit .env with your real keysRequired variables:
RPC_URLโ Sepolia or mainnet RPC endpoint (Alchemy / Infura)PRIVATE_KEYโ Bot wallet private key (hex, no0xprefix)IDENTITY_REGISTRY_ADDRESSโ ERC-8004 Identity Registry contractREPUTATION_REGISTRY_ADDRESSโ ERC-8004 Reputation Registry contractVALIDATION_REGISTRY_ADDRESSโ ERC-8004 Validation Registry contract
Optional (for full AI reasoning):
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYโ Amazon Bedrock credentialsDEX_ENABLED=trueโ Enable live Uniswap V3 swaps
3. Register Agent (one-time)
python main.py --register4. Run
# Single decision cycle
python main.py
# Continuous trading loop
python main.py --loop
# Launch the dashboard
streamlit run streamlit_app.pyRisk Management
Protocol Zero enforces a fail-closed risk pipeline โ if any check is uncertain, the trade is blocked. Six independent checks run in sequence:
ERC-8004 Compliance
Protocol Zero implements all three ERC-8004 registries:
- Identity Registry โ Agent mints an ERC-721 NFT with
register(agentURI), stores metadata viasetMetadata - Reputation Registry โ Every trade result is logged via
giveFeedback()with PnL, tags, and content hashes - Validation Registry โ Trade intents are submitted via
validationRequest()with EIP-712 signatures
Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=. --cov-report=term-missing
# Run a specific module's smoke test
python risk_check.py
python eip712_signer.py
python sign_trade.py --json '{"action":"BUY","asset":"ETH","confidence":0.8,"risk_score":3,"position_size_percent":1.0,"stop_loss_percent":3.0,"take_profit_percent":6.0,"market_regime":"TRENDING"}'Test Coverage
๐ค Amazon Nova AI Integration
Protocol Zero integrates four Amazon Nova services through Bedrock, with transparent fallback engines for each:
Nova Lite โ Agentic Market Reasoning โ
The brain uses the Bedrock Converse API with tool-use to make trading decisions. The LLM can request additional data mid-reasoning by calling tools:
rug_pull_scannerโ Check contracts for scam indicatorsmarket_deep_diveโ Fetch real-time order-book depth from CCXTnova_act_auditโ Browser-based contract verificationembedding_scanโ Scam-pattern detection on token metadata
This is the strongest integration โ a real agentic loop with tool orchestration.
Nova Voice Intelligence โก
Uses Nova Lite Converse API for intelligent text responses to voice commands. Browser-side Web Speech API handles text-to-speech playback. A Nova Sonic bidirectional stream session is initialised for future audio I/O, but audio frame processing is not yet wired. Falls back to rule-based text responses when AWS is unavailable.
Nova Act โ Browser-Based Smart Contract Auditing โฌ๏ธ
The code implements real Nova Act browser automation for Etherscan/DEXTools auditing. However, the nova-act SDK is invite-only and not publicly available. The system falls back to deterministic heuristic audits that honestly label themselves as "audit_method": "simulated".
Nova Multimodal Embeddings โ Scam Detection โ
Generates real embeddings via amazon.nova-embed-multimodal-v1:0 and compares them against reference pattern vectors using cosine similarity. Falls back to keyword/hash heuristics when AWS is unavailable.
All Nova services are optional โ the system gracefully falls back to rule-based engines and text-mode responses when AWS credentials are not configured. Fallback modes are clearly labeled in the dashboard.
๐ง Troubleshooting
"AWS credentials not ready โ using rule-based fallback brain"
This is normal when AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are not set. The system uses a technical-indicator-driven fallback engine (RSI + SMA crossovers).
"ValidationException: Operation not allowed" (Bedrock Converse)
If your dashboard shows AWS as configured but Bedrock runtime calls fail with:
ValidationException: Operation not allowed
this usually means partial AWS access:
- IAM credentials are valid
- control-plane checks may work
- but runtime model invocation is blocked at account/org/region/model level
In this state, Protocol Zero now:
- marks Nova Brain as BLOCKED/FALLBACK in status views
- suppresses noisy retry loops
- uses the deterministic rule-based decision engine until Bedrock runtime access is enabled
To fix at AWS side:
- Verify Bedrock model access approval for
amazon.nova-lite-v1:0 - Confirm region alignment (
AWS_DEFAULT_REGION) - Check org SCP/permission boundaries for
bedrock:Converse/bedrock:InvokeModel - Open AWS Support if runtime remains blocked despite IAM allow policies
"Cannot reach RPC" error
Check your RPC_URL in .env. For local testing, start Anvil:
anvil --chain-id 31337Then set RPC_URL=http://127.0.0.1:8545 in .env.local.
"nova-act" install fails
nova-act is an invite-only SDK. It's commented out of requirements.txt. Install it manually if you have access: pip install nova-act. The system falls back to simulated audits when unavailable.
Dashboard won't start
# Make sure Streamlit is installed
pip install streamlit plotly
# Run from the project root
streamlit run streamlit_app.py --server.port 8502EIP-712 signature mismatch
Ensure CHAIN_ID and VALIDATION_REGISTRY_ADDRESS in your .env match the values hard-coded in your deployed contract. The EIP-712 domain separator must be identical on both sides.
Project Structure
Protocol-Zero/
โโโ brain.py # AI reasoning engine (Nova Lite + tool-use)
โโโ chain_interactor.py # Web3 bridge for ERC-8004 registries
โโโ config.py # Centralized .env loader with validation
โโโ dashboard.py # Streamlit cinematic dashboard
โโโ streamlit_app.py # Streamlit Cloud entrypoint (main module)
โโโ dex_executor.py # Uniswap V3 live swap execution
โโโ eip712_signer.py # EIP-712 structured data signing
โโโ exceptions.py # Custom exception hierarchy
โโโ main.py # Orchestrator โ full agent lifecycle
โโโ metadata_handler.py # ERC-8004 agent-identity.json generator
โโโ nova_act_auditor.py # Nova Act browser-based contract auditing
โโโ nova_embeddings.py # Nova multimodal embedding scam detection
โโโ nova_sonic_voice.py # Nova Sonic bidirectional voice interface
โโโ performance_tracker.py # Session analytics (Sharpe, drawdown, etc.)
โโโ requirements.txt # Python dependencies
โโโ pyproject.toml # Project metadata & optional dependencies
โโโ risk_check.py # 6-layer fail-closed risk gate
โโโ sign_trade.py # Trade intent validator & signer
โโโ validation_artifacts.py # Cryptographic audit trail builder
โโโ tests/ # Unit & integration tests
โ โโโ test_brain.py # Brain rule-engine + parser tests
โ โโโ test_eip712_signer.py # EIP-712 signing + nonce persistence
โ โโโ test_exceptions.py # Exception hierarchy tests
โ โโโ test_metadata_handler.py # Metadata generation & hashing
โ โโโ test_nova_sonic_voice.py # Voice command parser & fallback
โ โโโ test_performance_tracker.py # Performance metrics tests
โ โโโ test_risk_check.py # Risk gate tests
โ โโโ test_sign_trade.py # Trade intent signing tests
โ โโโ test_validation_artifacts.py # Artifact data structure tests
โโโ .env.example # Environment variable template (copy to .env)
โโโ .gitignore # Git exclusions
โโโ LICENSE # MIT license
โโโ README.md # This fileLicense
MIT โ see LICENSE for details.
๐ Hackathon
Built for the Amazon Nova AI Hackathon on Devpost.
Protocol Zero demonstrates how autonomous AI agents can operate transparently on-chain using the ERC-8004 standard, with Amazon Nova providing the cognitive backbone:
- Nova Lite โ Agentic reasoning with tool-use (real Converse API)
- Nova Voice โ Text intelligence + browser-side Web Speech API
- Nova Act โ Browser-based contract auditing (simulated; SDK is invite-only)
- Nova Embeddings โ Cosine-similarity scam detection (real embeddings when AWS available)
Every decision is cryptographically signed (EIP-712), risk-gated (6 independent checks), and logged on-chain (Validation Registry) โ creating a complete audit trail that proves the agent's reasoning was sound before execution.
Capital preservation first, profit second. ๐ก๏ธ
