A complete demonstration of the ERC-8004 Trustless Agents standard with AI Agents.
This example showcases how AI agents can interact trustlessly across organizational boundaries using the ERC-8004 registry system, demonstrating the future of decentralized AI collaboration.
- β ERC-8004 Registry Contracts: Identity, Reputation, and Validation registries
- β AI Agents: Using CrewAI for sophisticated market analysis and validation
- β Trustless Interactions: Agents discover, validate, and provide feedback without pre-existing trust
- β Complete Audit Trail: Full blockchain-based accountability and transparency
- β Multi-Agent Workflows: Collaborative AI systems working together
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Server Agent β β Validator Agent β β Client Agent β
β (Alice) β β (Bob) β β (Charlie) β
β β β β β β
β β’ Market β β β’ Valdidation β β β’ Feedback β
β Analysis β β β Authorization β
β β’ Multi-agent β β β’ Quality β β β’ Reputation β
β workflows β β Assessment β β Management β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββββββ
β ERC-8004 Registriesβ
β β
β β’ Identity Registry β
β β’ Reputation Registryβ
β β’ Validation Registryβ
βββββββββββββββββββββββ
- Python 3.8+ with pip
- Node.js 16+ with npm (for Foundry)
- Foundry (for smart contracts)
-
Clone and setup the example:
git clone https://github.com/chaoschain/erc-8004-example.git cd erc-8004-example # Option 1: Automated setup (recommended) ./setup.sh # Option 2: Manual setup pip install -r requirements.txt curl -L https://foundry.paradigm.xyz | bash foundryup
-
Compile the smart contracts:
cd contracts forge install forge build cd ..
-
Configure environment:
cp .env.example .env # Edit .env with your configuration
-
Start a local blockchain (optional):
# In a separate terminal anvil
python demo.py
- Deploys the three ERC-8004 registry contracts
- Creates a complete trustless infrastructure
- Alice (Server Agent): Market analysis service
- Bob (Validator Agent): Analysis validation service
- Charlie (Client Agent): Feedback and reputation management
- All agents register with the Identity Registry
- Receive unique on-chain identities and agent IDs
- Alice performs comprehensive BTC market analysis
- Multi-agent workflow with analyst and reviewer roles
- Generates structured analysis with recommendations
- Alice submits her analysis for validation by Bob
- Creates cryptographic hash of the work
- Stores analysis data for validator access
- Bob validates Alice's analysis
- Multi-agent validation with validator and QA specialist roles
- Generates validation score and detailed feedback
- Bob submits validation score (0-100) on-chain
- Creates permanent, immutable validation record
- Charlie authorizes feedback for Alice's services
- Enables reputation building and trust networks
- Complete blockchain-based audit trail
- Full transparency and accountability
- Role: Market Analysis Service Provider
- Capabilities:
- Senior Market Analyst for trend identification
- Risk Assessment Specialist for validation
- Structured analysis with confidence scores
- Professional reporting standards
- Role: Analysis Validation Service
- Capabilities:
- Senior Analysis Validator for methodology review
- Quality Assurance Specialist for final assessment
- Comprehensive scoring (0-100)
- Detailed feedback and improvement recommendations
erc-8004-example/
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ .env.example # Environment configuration template
βββ demo.py # Main demonstration script
βββ setup.sh # Automated setup script
βββ SUMMARY.md # Project summary
βββ ERC-XXXX Trustless Agents v0.3.md # ERC specification
β
βββ contracts/ # Smart contracts
β βββ src/ # Contract source code
β β βββ IdentityRegistry.sol
β β βββ ReputationRegistry.sol
β β βββ ValidationRegistry.sol
β β βββ interfaces/ # Contract interfaces
β βββ out/ # Compiled artifacts (ABIs)
β βββ script/ # Deployment scripts
β βββ foundry.toml # Foundry configuration
β
βββ agents/ # AI agent implementations
β βββ __init__.py
β βββ base_agent.py # Base ERC-8004 agent class
β βββ server_agent.py # Market analysis server agent
β βββ validator_agent.py # Analysis validation agent
β
βββ scripts/ # Utility scripts
β βββ deploy.py # Contract deployment script
βββ data/ # Generated analysis data (created at runtime)
βββ validations/ # Generated validation data (created at runtime)
# Blockchain Configuration
RPC_URL=http://127.0.0.1:8545 # Local Anvil
PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000
CHAIN_ID=31337
# Agent Domains (optional)
AGENT_DOMAIN_ALICE=alice.example.com
AGENT_DOMAIN_BOB=bob.example.com
# AI Configuration (optional - for enhanced AI features)
# The demo works without these, using fallback analysis
# OPENAI_API_KEY=your_openai_api_key_here
# ANTHROPIC_API_KEY=your_anthropic_api_key_here
The example works with any EVM-compatible network:
- Local Development: Anvil/Hardhat (default)
- Testnets: Sepolia, Goerli, Base Sepolia
- Mainnets: Ethereum, Base, Arbitrum, Optimism
Simply update the RPC_URL
and CHAIN_ID
in your .env
file.
After running this example, you'll understand:
- ERC-8004 Standard: How trustless agent interactions work
- Registry Architecture: Identity, reputation, and validation systems
- Blockchain Integration: Smart contract interaction patterns
- Trust Models: How agents build reputation without pre-existing relationships
- Identity Registry: Sovereign, portable agent identities
- Reputation Registry: Decentralized feedback and rating systems
- Validation Registry: Cryptoeconomic validation mechanisms
- Multi-Agent Workflows: Collaborative AI systems
- Structured Analysis: Professional-grade market analysis
- Quality Validation: AI-powered validation and scoring
- Continuous Learning: Agents improve through feedback
- Smart Contract Interaction: Seamless Web3 integration
- Event Monitoring: Real-time blockchain event handling
- Gas Optimization: Efficient transaction patterns
- Multi-Network Support: Works across EVM chains
- Create a new agent class inheriting from
ERC8004BaseAgent
- Implement AI workflows for your specific use case
- Define trust models your agent supports
- Update the demo script to include your agent
- Replace mock data in
MarketAnalysisTool
with real API calls - Add authentication for external services
- Implement error handling for network failures
- Add rate limiting for API usage
- Use secure key management (not hardcoded private keys)
- Deploy to testnets first for validation
- Implement proper monitoring and logging
- Add comprehensive error handling
This example is designed to be educational and extensible. Contributions are welcome:
- Bug fixes and improvements
- New agent types and use cases
- Additional trust models and validation methods
- Documentation and tutorials
- ERC-8004 Specification: https://eips.ethereum.org/EIPS/eip-8004
- CrewAI Documentation: https://docs.crewai.com/
- A2A Protocol: https://a2a-protocol.org/
- Foundry Book: https://book.getfoundry.sh/
- Demo Purpose: This is an educational example, not production-ready code
- Security: Use proper key management in production environments
- Gas Costs: Monitor transaction costs on mainnet deployments
- AI Functionality: Demo works fully without API keys using fallback analysis
- With API keys: Full AI-powered analysis via CrewAI + LLMs
- Without API keys: Intelligent fallback analysis (still demonstrates all ERC-8004 features)
- Network Requirements: Requires a running blockchain (Anvil recommended for local testing)
When you run this example successfully, you'll see:
- β All contracts deployed and verified
- β Three agents registered with unique IDs (Alice: Server, Bob: Validator, Charlie: Client)
- β Complete market analysis generated by AI (BTC analysis with trend, support/resistance levels)
- β Professional validation with scoring (96-100/100 validation scores)
- β Full blockchain audit trail with transaction hashes
- β Trustless agent interactions demonstrated across 7 steps
Expected Output: The demo runs through all 7 steps, showing real multi-agent workflows performing market analysis and validation, even without external API keys (using intelligent fallback analysis).
This example proves that sophisticated AI agents can work together trustlessly, laying the foundation for a decentralized agent economy!
Built with β€οΈ for the ERC-8004 Trustless Agents standard