A blockchain-based consensus mechanism that mines soulbound KEY tokens through verified AI intelligence work, implementing Vector Logical Clocks (VLC) for causal ordering and Byzantine Fault Tolerant consensus.
This system demonstrates a novel approach to cryptocurrency mining where tokens are earned through actual valuable AI work rather than computational waste. The KEY token represents verifiable intelligence contributions and is non-transferable (soulbound) but redeemable.
- π§ Intelligence Mining: Earn KEY tokens through actual AI task completion
- π Vector Logical Clocks: Causal ordering of distributed consensus events
- ποΈ Byzantine Fault Tolerant: 4-validator consensus with quality assessment
- π Soulbound Tokens: Non-transferable but redeemable KEY tokens
- π Real-time Visualization: VLC event graph via Dgraph
- βοΈ Blockchain Integration: Smart contracts on Anvil/Ethereum
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Subnet β β Bridge β β Blockchain β
β β β β β β
β Miner + 4 βββββΊβ HTTP Server βββββΊβ Smart Contracts β
β Validators β β (Port 3001) β β (Anvil) β
β β β β β β
β VLC Consensus β β Per-epoch β β KEY Mining β
βββββββββββββββββββ β Submission β β Token Rewards β
β ββββββββββββββββββββ βββββββββββββββββββ
βΌ
βββββββββββββββββββ
β Dgraph β
β VLC Graph β
β Visualization β
βββββββββββββββββββ
Purpose: Pure subnet consensus demonstration with VLC visualization (no blockchain integration)
What it does:
- β Runs distributed consensus with 1 miner + 4 validators
- β Processes 7 rounds of AI tasks with quality assessment
- β Generates VLC event graph for causal analysis
- β Provides interactive exploration of consensus behavior
- β No blockchain integration or KEY token mining
Run Command:
./run-subnet-only.shAccess Points:
- π VLC Graph:
http://localhost:8000(Dgraph Ratel UI) - π Event Query:
http://localhost:8080/graphql
Purpose: Complete PoCW system with real KEY token mining and blockchain integration
What it does:
- β Everything from subnet-only mode PLUS:
- β Deploys smart contracts (KEY Token, PoCW Verifier, etc.)
- β Real-time KEY mining per epoch (every 3 rounds)
- β Blockchain transactions with verified rewards
- β Bridge service for epoch submission
- β Complete before/after balance tracking
Run Command:
./run-key-mining.shAccess Points:
- π VLC Graph:
http://localhost:8000 - π Blockchain Inspector:
http://localhost:3000/pocw-inspector.html - βοΈ Blockchain RPC:
http://localhost:8545 - π Bridge API:
http://localhost:3001
# Install Foundry (for Anvil and Cast)
curl -L https://foundry.paradigm.xyz | bash
foundryup
# Install Go >= 1.21
# Install Node.js >= 22
# Install Docker (for Dgraph)
# Install bc (for calculations)
sudo apt install bc- Ports: 3000, 3001, 8000, 8080, 8545, 9080 (must be available)
- Docker: Required for Dgraph container
- Sudo Access: Required for Docker operations
# Clean run of subnet consensus with VLC visualization
sudo ./run-subnet-only.sh
# Access VLC graph at http://localhost:8000
# Press Ctrl+C when done exploring# Complete PoCW system with blockchain integration
sudo ./run-key-mining.sh
# Watch KEY tokens being mined in real-time
# Explore blockchain inspector at http://localhost:3000/pocw-inspector.html
# Bridge stays active for continued mining
# Press Ctrl+C when done| Contract | Purpose | Features |
|---|---|---|
| KEYToken | Soulbound intelligence tokens | Non-transferable, 21M max supply |
| HETUToken | Staking for subnet registration | ERC20, 1M total supply |
| SubnetRegistry | Manages subnet participants | Deposit requirements, validation |
| EnhancedPoCWVerifier | Consensus verification & mining | Per-epoch KEY distribution |
πΉ PoCW SUBNET-ONLY DEMONSTRATION
Architecture: Pure subnet consensus with VLC graph visualization
β
7 rounds processed with Byzantine consensus
β
VLC events committed to Dgraph
π Interactive mode - explore at http://localhost:8000
π° PoCW KEY MINING SYSTEM
Architecture: Complete KEY mining with blockchain integration
π° Initial KEY Token Balances (Before Mining)
π Miner: 0.000000 KEY
π Validator-1: 0.000000 KEY
...
[CONSENSUS & MINING HAPPENS]
π° Final KEY Token Balances (After Mining)
π Miner: 400.000000 KEY (+400.000000 KEY mined)
π Validator-1: 25.000000 KEY (+25.000000 KEY mined)
π Total Supply: 500.000000 KEY (+500.000000 KEY total mined)
π Bridge stays running for continued KEY mining!
- Round: Single AI task with miner output + validator consensus
- Epoch: 3 consecutive rounds
- Mining Trigger: Each completed epoch triggers KEY token mining
- Ensures causal ordering of distributed events
- Tracks happened-before relationships
- Prevents Byzantine inconsistencies
- Visualized as directed graphs in Dgraph
- Mining Rate: Based on successful task completion
- Distribution: 80% to miner, 20% split among validators
- Soulbound: Cannot be transferred, but can be redeemed
- Max Supply: 21 million KEY (like Bitcoin)
Port Conflicts:
# Check what's using required ports
netstat -tlnp | grep -E ":(3000|3001|8000|8080|8545|9080)"
# Kill conflicting processes if neededDocker Permissions:
# Run the scripts with sudo to handle Docker operations
sudo ./run-subnet-only.sh
sudo ./run-key-mining.shBridge Connection Errors:
- Ensure Node.js dependencies are installed:
npm install - Bridge starts after contract deployment in key-mining mode
- Check bridge health:
curl http://localhost:3001/health
Dgraph Issues:
- Wait 30+ seconds for Dgraph container to fully start
- Try accessing Ratel UI directly:
http://localhost:8000 - Check container:
docker ps | grep dgraph
# If anything gets stuck, clean everything:
pkill anvil
sudo docker stop dgraph-standalone
sudo docker rm dgraph-standalone
sudo rm -rf ./dgraph-data
rm -f contract_addresses.json *.log *.pidπ€ CoreMiner
- AI agents that process user tasks and requests
- Maintain Vector Logical Clock (VLC) consistency
- Generate responses and request additional context when needed
- Process 7 different test scenarios demonstrating various interaction patterns
π‘οΈ CoreValidator
- Quality assessment nodes that vote on miner outputs
- Two specialized roles:
- UserInterfaceValidator: Handles user interaction and info requests
- ConsensusValidator: Performs distributed quality voting
- Byzantine Fault Tolerant consensus with 0.25 weight per validator
- Validates VLC sequences and ensures causal consistency
β° Vector Logical Clocks (VLC)
- Ensures causal ordering of all operations
- Tracks dependencies between events across the network
- Prevents out-of-order execution and maintains consistency
- Critical for distributed consensus and event validation
π Graph Visualization
- Real-time VLC event tracking via Dgraph database
- Interactive visualization of causal relationships
- Event categorization: UserInput, MinerOutput, InfoRequest, RoundSuccess, etc.
- Complete audit trail of all network interactions
The subnet demo processes 7 test scenarios that showcase all aspects of the PoCW protocol:
- User Input: "Analyze market trends for Q4"
- Miner Response: Direct solution generation
- Validator Assessment: Quality voting and consensus
- User Feedback: Acceptance confirmation
- Result:
OUTPUT DELIVERED TO USER
- User Input: "Create optimization strategy for resource allocation"
- Miner Behavior: Requests additional context
- Validator Mediation: Facilitates user-miner communication
- Enhanced Processing: Solution with additional context
- Advanced Validation: Quality assessment of refined output
- Validator Rejection: Low-quality output rejected by consensus (0.45 quality score)
- Result:
OUTPUT REJECTED BY VALIDATORS
- Validator Acceptance: Output passes validator consensus
- User Rejection: User rejects despite validator approval
- Result:
OUTPUT REJECTED BY USER (despite validator acceptance)
After running the demonstration, visualize the complete VLC event graph:
- Open Ratel UI: http://localhost:8000
- Verify Connection: Ensure connection shows
localhost:8080 - Query Events: Use this GraphQL query to view all subnet events:
{
events(func: has(event_id)) {
uid
event_id
event_name
event_type
subnet_id
request_id
vlc_clock
parents {
uid
event_id
event_name
}
timestamp
description
}
}- π― UserInput: User task submissions (7 scenarios)
- π€ MinerOutput: AI agent responses and solutions
- β InfoRequest: Miner requests for additional context
- π¬ InfoResponse: User-provided clarifications
- β RoundSuccess: Successful consensus rounds
- β RoundFailed: Failed validation or user rejection
- π EpochFinalized: Subnet epoch completion markers
- β GenesisState: Initial subnet state
- Parent Links: Show causal dependencies between events
- VLC Clocks: Demonstrate proper ordering (format:
{miner:X, validator:Y})
The graph provides a complete audit trail showing how each user request flows through the subnet, demonstrating the causal consistency guarantees of the PoCW protocol.
PoCW extends traditional blockchain consensus by focusing on causal relationships rather than just computational work:
π Causal Consistency
- Every event must reference its causal dependencies
- Vector Logical Clocks ensure proper ordering across distributed nodes
- Invalid causal relationships are automatically rejected
- Creates immutable audit trail of decision-making processes
ποΈ Byzantine Fault Tolerant Consensus
- 4 validators with 0.25 weight each (total weight = 1.0)
- Requires majority consensus for output acceptance
- Handles up to 1 Byzantine (malicious) validator
- Quality threshold-based voting (accept if quality > 0.5)
β‘ Event-Driven Architecture
- Real-time processing of user requests
- Dynamic info request/response cycles
- Asynchronous validator consensus
- Complete traceability of all interactions
PoCW subnets can be bridged to mainnet blockchains for broader ecosystem integration:
π Subnet to Mainnet Flow:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β PoCW Subnet βββββΆβ Epoch Finalize βββββΆβ Mainnet Post β
β β β β β β
β β’ Miners β β β’ VLC State β β β’ Smart Contractβ
β β’ Validators β β β’ Consensus β β β’ TOKEN Mining β
β β’ VLC Graph β β β β β’ Verification β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
Intelligence Money represents verifiable units of intelligent work - the first digital asset derived from provable AI contributions rather than energy consumption.
π― Core Principles
Traditional Crypto: Energy β Computational Work β Token Value
Intelligence Money: AI Work β Verified Contribution β KEY Value
ποΈ The Mining Process
- Query Initiation: User submits complex problem to subnet
- AI Collaboration: Miners and validators work together via PoCW
- Quality Validation: BFT consensus ensures solution quality
- Value Attribution: Successful contributions mine new KEY tokens
- Cryptographic Proof: VLC graph provides immutable work evidence
β‘ Real-Time Mining
- Every accepted user solution mines new tokens
- Quality multipliers affect mining rewards
- Validator consensus participation earns rewards
- Failed outputs generate no tokens (merit-based system)
π Non-Transferable Design
- Soulbound: KEY tokens cannot be transferred between addresses
- Reputation-Based: Tokens represent earned capability and track record
- Anti-Speculation: Prevents market manipulation and speculation bubbles
- Cryptographic Resume: Immutable proof of AI agent competence
π΅ Liquidity Bridge
- Redemption Pool: One-way bridge to stablecoins (USDC/USDT)
- Burn Mechanism: KEY tokens are destroyed when redeemed
- Market Valuation: Exchange rate determined by supply/demand
- Utility Preservation: Core reputation asset remains non-transferable
π VALUE FLOW:
User Problem βββΆ AI Solution βββΆ Quality Validation βββΆ KEY Mining βββΆ Stablecoin Redemption
β² β β
ββββββββ Economic Feedback Loop ββββββββ΄βββββββββββββββββββββββββββββββ
This creates a merit-only economy where value flows directly from problem-solving capability to economic rewards, eliminating speculative intermediaries and ensuring AI agents are compensated based purely on their verifiable contributions to human knowledge and productivity.
Intelligence-KEY-Mining/
βββ main.go # Entry point - subnet demonstration
βββ go.mod # Go module dependencies
βββ run-subnet-only.sh # Subnet consensus only mode
βββ run-key-mining.sh # Full KEY mining mode
βββ run-per-epoch-integration.sh # Alternative KEY mining script
βββ serve-dashboard.go # Web UI server (integrated into scripts)
βββ mainnet-bridge-per-epoch.js # HTTP bridge service (port 3001)
βββ pocw-inspector.html # Blockchain inspector UI
βββ contracts/ # Solidity smart contracts
β βββ KEYToken.sol # Soulbound KEY tokens
β βββ HETUToken.sol # Staking token
β βββ SubnetRegistry.sol # Subnet management
β βββ EnhancedPoCWVerifier.sol # Consensus verification
βββ subnet/ # Go consensus implementation
β βββ core_miner.go # AI miner agents
β βββ core_validator.go # BFT validators
β βββ graph_adapter.go # VLC graph & HTTP bridge integration
β βββ messages.go # Protocol message definitions
β βββ demo/ # Demo scenarios & coordination
β βββ demo_coordinator.go # Demo orchestration
β βββ demo_task_processor.go # Task processing logic
β βββ demo_quality_assessor.go # Quality assessment
β βββ demo_user_interaction.go # User interface simulation
βββ vlc/ # Vector Logical Clock library
β βββ vlc.go # VLC implementation
βββ dgraph/ # Graph database integration
β βββ connection.go # Dgraph client connection
β βββ init.go # Dgraph initialization
βββ models/ # Data models
β βββ event.go # Event structure definitions
βββ tests/ # Test utilities
βββ test-enhanced-pocw.js # JavaScript contract tests
βββ test-enhanced-pocw.sh # Shell test runner
- Subnet Logic: Modify files in
subnet/directory - Smart Contracts: Update contracts in
contracts/directory - Bridge Logic: Enhance
mainnet-bridge-per-epoch.js - UI Components: Update
pocw-inspector.html
MIT License - See LICENSE for details.
- Fork the repository
- Create a feature branch
- Test with both
./run-subnet-only.shand./run-key-mining.sh - Submit a pull request
π Start with ./run-subnet-only.sh to understand the consensus, then try ./run-key-mining.sh for the full KEY mining experience!
Intelligence Money represents the next evolution of digital assets - from energy-based mining to intelligence-based value creation. This system shows how AI agents can collaborate, compete, and be fairly compensated in a trustless, merit-based economy.