Skip to content

ChaosChain/chaoschain-dvn

Repository files navigation

ChaosChain DVN PoC

Decentralized Verification Network Proof-of-Concept for AI Agent Collaboration

Solidity Hardhat License: MIT Tests


🚀 Overview

ChaosChain DVN PoC demonstrates the first Decentralized Verification Network for AI agent collaboration. This system enables Worker Agents to submit verifiable work for evaluation by a network of Verifier Agents, creating immutable Proof-of-Agency records on the blockchain.

🎯 Key Innovation

Unlike traditional blockchain systems that verify transactions, the DVN verifies the quality and correctness of AI agent work, enabling trusted multi-agent collaboration at scale.


🏗️ Architecture

┌─────────────────────────────────────────────────────────────────────────────┐
│                           ChaosChain DVN Architecture                       │
└─────────────────────────────────────────────────────────────────────────────┘

Off-Chain Components                Smart Contracts (Sepolia)
┌─────────────────┐                ┌──────────────────────────┐
│  Worker Agent   │───────────────▶│     DVNRegistryPOC       │
│                 │    Register    │  (Agent Registration)    │
└─────────────────┘                └──────────────────────────┘
                                                   ▲
┌─────────────────┐                                │
│ Verifier Agents │────────────────────────────────┘
│                 │         Register & Stake
└─────────────────┘                
        │                          ┌──────────────────────────┐
        │                          │       StudioPOC          │
        │   ┌─────────────────┐    │   (KiranaAI Use Case)    │
        │   │  IPFS Storage   │◀───┤  - Receives PoA Hash     │
        │   │  (PoA Packages) │    │  - Collects Fees         │
        │   └─────────────────┘    └──────────────────────────┘
        │            ▲                           │
        │            │                           ▼
        │            │               ┌─────────────────────────┐
        │      ┌─────────────────┐   │    DVNConsensusPOC      │
        │      │  Worker Agent   │──▶│   (Consensus Engine)    │
        │      │                 │   │  - Processes Results    │
        │      └─────────────────┘   │  - Updates PoA Status   │
        │                            └─────────────────────────┘
        │                                       │ ▲
        │                                       │ │
        │                                       ▼ │
        │                            ┌─────────────────────────┐
        └───────────────────────────▶│   DVNAttestationPOC     │
             Submit Attestations     │ (Attestation Recording) │
                                     │  - Records VA Votes     │
                                     │  - Prevents Double Vote │
                                     └─────────────────────────┘

Workflow

  1. Agent Registration: Worker Agents (WAs) and Verifier Agents (VAs) register with DVNRegistryPOC.sol, with VAs performing a mock stake.
  2. Work Package Creation & Upload: A WA performs a task defined by a Studio (e.g., the "KiranaAI-POC-Studio"). The WA then creates a "Work Submission Package" (e.g., a JSON file containing task details, outputs, and context) and uploads this package to IPFS.
  3. Work Submission to Studio: The WA submits a reference to this Work Submission Package (the IPFS hash) to the StudioPOC.sol contract, initiating a new Proof-of-Agency lifecycle. This generates a unique poaId.
  4. Verification Triggered & Attestation:
    • The submission to StudioPOC.sol signals that a new poaId is ready for verification.
    • Registered and staked VAs monitor for these new submissions (e.g., by listening to WorkSubmitted events).
    • VAs fetch the Work Submission Package from IPFS, evaluate it against the Studio's criteria, and submit their attestations (approve/reject) to DVNAttestationPOC.sol, referencing the poaId.
  5. Consensus & Proof-of-Agency Finalization:
    • After attestations are collected, the DVNConsensusPOC.sol contract processes these attestations for the given poaId.
    • Based on its defined consensus logic (e.g., majority vote), it determines if the work is valid.
    • DVNConsensusPOC.sol then instructs StudioPOC.sol to update the status of the poaId to VERIFIED or REJECTED.
  6. Proof-of-Agency Recorded: If the status is VERIFIED, the poaId (linked to the original submission details and its VERIFIED status on-chain in StudioPOC.sol) now serves as the immutable Proof-of-Agency. An event like ProofOfAgencyFinalized confirms this.

Smart Contracts

This PoC is composed of the following core smart contracts deployed on the Sepolia testnet:

Contract Name Description Sepolia Address
DVNRegistryPOC Agent registration and staking management 0x5A6207a7...0aB599fE
StudioPOC KiranaAI inventory verification studio 0x03ed96a2...Acac40De
DVNAttestationPOC Verifier agent attestation recording 0x950B75d0...BCA5541F
DVNConsensusPOC Consensus processing and finalization 0x33807533...Ea0771dDa
IStudioPolicy Standard interface for all Studios (N/A - Interface Only)

✨ Features

🤖 Agent Management

  • Worker Agent Registration: Submit work for verification
  • Verifier Agent Registration: Evaluate and attest to submissions
  • Reputation System: Dynamic reputation scoring (100-1000 range)
  • Staking Mechanism: Economic security through ETH staking

🏪 Studio System

  • KiranaAI Integration: Inventory verification use case
  • Flexible Action Types: Support for multiple verification scenarios
  • Fee Structure: 0.0001 ETH verification fees
  • Custom Policies: Studio-specific verification criteria

⚖️ Consensus Engine

  • Configurable Parameters: 3 minimum attestations, 66% threshold
  • Weighted Voting: Stake × reputation weighting
  • Timeout Protection: 10-minute attestation windows
  • Reward Distribution: Automatic verifier compensation

🔒 Security & Trust

  • Proof-of-Agency: Immutable verification records
  • Anti-Double-Voting: Prevents duplicate attestations
  • Access Control: Role-based permissions
  • Slashing Protection: Economic penalties for misbehavior

📋 Prerequisites

  • Node.js v16+
  • npm or yarn
  • Git
  • Ethereum wallet with Sepolia testnet ETH
  • RPC Provider (Infura, Alchemy, etc.)

🚀 Quick Start

1. Installation

# Clone the repository
git clone https://github.com/ChaosChain/chaoschain-dvn.git
cd chaoschain-dvn

# Install dependencies
npm install

# Copy environment template
cp config/environment.example .env

2. Environment Setup

Edit .env with your configuration:

# Sepolia testnet configuration
SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_PROJECT_ID
PRIVATE_KEY=your_private_key_without_0x_prefix
ETHERSCAN_API_KEY=your_etherscan_api_key

3. Compile & Test

# Compile contracts
npm run compile

# Run tests
npm test

# Test with gas reporting
REPORT_GAS=true npm test

4. Deploy

# Deploy to Sepolia testnet
npm run deploy:sepolia

# Or deploy locally for testing
npm run deploy:local

🧪 Testing

The project includes comprehensive test coverage:

# Run all tests
npm test

# Run specific test file
npx hardhat test tests/unit/DVNRegistry.test.js

# Generate coverage report
npm run coverage

Test Results

✅ 15/15 Tests Passing
✅ Agent Registration & Management
✅ Staking Mechanisms
✅ Work Submission Workflow
✅ Attestation Recording
✅ Access Control & Security

📖 Usage Examples

Register a Verifier Agent

const DVNRegistry = await ethers.getContractFactory("DVNRegistryPOC");
const registry = DVNRegistry.attach(contractAddress);

// Register as verifier
const agentId = ethers.utils.formatBytes32String("verifier-001");
await registry.registerAgent(agentId, 1, "https://my-endpoint.com");

// Stake ETH
await registry.mockStake({ value: ethers.utils.parseEther("0.01") });

Submit Work to Studio

const StudioPOC = await ethers.getContractFactory("StudioPOC");
const studio = StudioPOC.attach(studioAddress);

// Submit inventory verification work
const poaId = await studio.submitWork(
  ethers.utils.formatBytes32String("worker-001"),
  "KiranaAI_StockReport",
  "QmIPFSHashOfSubmissionData",
  { value: ethers.utils.parseEther("0.0001") }
);

Submit Attestation

const DVNAttestation = await ethers.getContractFactory("DVNAttestationPOC");
const attestation = DVNAttestation.attach(attestationAddress);

// Verifier attests to submission
await attestation.submitAttestation(
  poaId,
  true, // approved
  "QmIPFSHashOfJustification"
);

🏪 KiranaAI Studio Demo

The PoC includes a complete KiranaAI inventory verification studio that demonstrates:

  • Worker Agents submit store inventory reports
  • Verifier Agents validate inventory accuracy
  • Consensus mechanism determines verification outcome
  • Proof-of-Agency records provide audit trail

Supported Action Types

  • KiranaAI_StockReport - Daily inventory counts
  • KiranaAI_InventoryAudit - Comprehensive audits
  • KiranaAI_ReorderAlert - Automated reorder triggers

📊 Contract Specifications

Economic Parameters

MINIMUM_STAKE = 0.001 ether;     // Minimum VA stake
VERIFICATION_FEE = 0.0001 ether; // Studio submission fee
INITIAL_REPUTATION = 100;        // Starting reputation
CONSENSUS_THRESHOLD = 66%;       // Approval threshold
ATTESTATION_TIMEOUT = 10 minutes; // Response window

Gas Optimization

  • Optimized for 200 compiler runs
  • Efficient storage patterns
  • Event-based data retrieval
  • Batch operations support

🛠️ Development

Project Structure

chaoschain-dvn/
├── contracts/           # Smart contracts
│   ├── interfaces/      # Contract interfaces
│   ├── DVNRegistryPOC.sol
│   ├── StudioPOC.sol
│   ├── DVNAttestationPOC.sol
│   └── DVNConsensusPOC.sol
├── scripts/            # Deployment scripts
├── tests/              # Test suite
├── docs/               # Documentation
├── config/             # Configuration files
└── agents/             # Python agents (Phase 2)

Available Scripts

npm run compile         # Compile contracts
npm test               # Run test suite
npm run deploy:sepolia # Deploy to Sepolia
npm run deploy:local   # Deploy locally
npm run clean          # Clean artifacts
npm run coverage       # Generate coverage

🔮 Roadmap

Phase 1: Smart Contracts ✅ COMPLETE

  • DVN core smart contract system
  • KiranaAI Studio implementation
  • Comprehensive testing suite
  • Sepolia deployment ready

Phase 2: Agent Automation 🚧 IN PROGRESS

  • Python Worker Agent scripts
  • Python Verifier Agent scripts
  • IPFS integration for metadata
  • End-to-end demo automation

Phase 3: Advanced Features 📋 PLANNED

  • Multi-studio support
  • Advanced consensus algorithms
  • ZK-proof integration
  • Cross-chain compatibility

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Make changes and add tests
  4. Ensure all tests pass: npm test
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open Pull Request

📚 Documentation


🔐 Security

Audit Status

  • Internal security review
  • External audit (planned)
  • Bug bounty program (planned)

Report Security Issues

Please report security vulnerabilities to: security@chaoschain.io


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🌟 Acknowledgments

  • OpenZeppelin for secure contract libraries
  • Hardhat for development framework
  • Ethereum Foundation for blockchain infrastructure
  • IPFS for decentralized storage

📞 Support & Community


Built with ❤️ by the ChaosChain team

Creating the future of verifiable AI agent collaboration 🚀

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published