Ensure you have the following installed:
- Node.js >= 18.0.0
- npm >= 9.0.0
- Git
node --version # Should be >= 18.0.0
npm --version # Should be >= 9.0.0# Clone the repository
git clone https://github.com/WGlynn/-Net-PsiNet---the-Psychic-Network-for-AI-Context.
cd -Net-PsiNet---the-Psychic-Network-for-AI-Context
# Checkout the ERC-8004 implementation branch
git checkout claude/network-breakdown-analysis-011CUsqavmBwpQxkBBirQVSH
# Install dependencies (takes ~2 minutes)
npm install# Copy environment template
cp .env.example .env
# Edit .env with your keys (optional for local testing)
nano .env # or use your preferred editorFor local testing, you can leave the default values. For deployment to testnet/mainnet, you'll need:
PRIVATE_KEY- Your wallet private keyINFURA_API_KEY- Get from https://infura.ioETHERSCAN_API_KEY- Get from https://etherscan.io
npm run compileExpected output:
Compiled 6 Solidity files successfully
This creates:
artifacts/- Compiled contract artifactscache/- Compilation cache
# Run all tests (180+ tests)
npm testExpected output:
IdentityRegistry
Deployment
✓ Should set the correct name and symbol
✓ Should start with zero agents
Agent Registration
✓ Should register a new agent
✓ Should increment agent IDs
... (50+ passing)
ReputationRegistry
Deployment
✓ Should set correct identity registry
✓ Should set correct minimum stake
Posting Feedback
✓ Should post positive feedback
... (60+ passing)
ValidationRegistry
Deployment
✓ Should set correct parameters
Request Validation
✓ Should request staked validation
... (70+ passing)
180 passing (5s)
npm run test:coverageExpected coverage:
- Line Coverage: > 95%
- Branch Coverage: > 90%
- Function Coverage: 100%
- Statement Coverage: > 95%
REPORT_GAS=true npm testExpected gas costs (at 50 Gwei):
| Operation | Gas Used | Cost @ 50 Gwei |
|---|---|---|
| Register Agent | ~150,000 | ~$2.50 |
| Post Feedback | ~100,000 | ~$1.67 |
| Post Staked Feedback | ~120,000 | ~$2.00 |
| Request Validation | ~80,000 | ~$1.33 |
| Submit Validation | ~120,000 | ~$2.00 |
# Test only Identity Registry
npx hardhat test test/IdentityRegistry.test.js
# Test only Reputation Registry
npx hardhat test test/ReputationRegistry.test.js
# Test only Validation Registry
npx hardhat test test/ValidationRegistry.test.js
# Run specific test by name
npx hardhat test --grep "Should register a new agent"# Terminal 1: Start local blockchain
npm run nodeExpected output:
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
Accounts
========
Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH)
Account #1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 (10000 ETH)
...
# Terminal 2: Deploy to local network
npm run deploy:localhostExpected output:
🚀 Starting ERC-8004 Registry Deployment for ΨNet...
📋 Deployment Details:
Network: localhost
Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
Balance: 10000.0 ETH
⚙️ Configuration:
Reputation Min Stake: 0.01 ETH
Validation Request Stake: 0.01 ETH
Validator Min Stake: 0.05 ETH
📝 [1/3] Deploying IdentityRegistry...
✅ IdentityRegistry deployed at: 0x5FbDB2315678afecb367f032d93F642f64180aa3
📝 [2/3] Deploying ReputationRegistry...
✅ ReputationRegistry deployed at: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
📝 [3/3] Deploying ValidationRegistry...
✅ ValidationRegistry deployed at: 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
🎉 DEPLOYMENT COMPLETE!
# Ensure .env has PRIVATE_KEY and INFURA_API_KEY
npm run deploy:sepolianpx hardhat verify --network sepolia <IDENTITY_REGISTRY_ADDRESS>
npx hardhat verify --network sepolia <REPUTATION_REGISTRY_ADDRESS> \
<IDENTITY_REGISTRY_ADDRESS> \
"10000000000000000"
npx hardhat verify --network sepolia <VALIDATION_REGISTRY_ADDRESS> \
<IDENTITY_REGISTRY_ADDRESS> \
"10000000000000000" \
"50000000000000000"# Deploy to Ethereum mainnet
npm run deploy:mainnet
# Or deploy to L2s for lower costs
npm run deploy:optimism # Optimism L2
npm run deploy:arbitrum # Arbitrum L2
npm run deploy:polygon # Polygon sidechain
npm run deploy:base # Base L2├── contracts/erc8004/ # Smart contracts
│ ├── IIdentityRegistry.sol # Identity interface
│ ├── IdentityRegistry.sol # Identity implementation
│ ├── IReputationRegistry.sol # Reputation interface
│ ├── ReputationRegistry.sol # Reputation implementation
│ ├── IValidationRegistry.sol # Validation interface
│ └── ValidationRegistry.sol # Validation implementation
├── test/ # Test suite (180+ tests)
│ ├── IdentityRegistry.test.js
│ ├── ReputationRegistry.test.js
│ ├── ValidationRegistry.test.js
│ └── README.md
├── scripts/
│ └── deploy.js # Deployment script
├── deployments/ # Deployment addresses (created after deploy)
├── artifacts/ # Compiled contracts (created after compile)
├── cache/ # Build cache (created after compile)
├── hardhat.config.js # Hardhat configuration
├── package.json # Dependencies and scripts
├── .env.example # Environment template
└── README.md # Main documentation
# Development
npm run compile # Compile contracts
npm test # Run tests
npm run test:coverage # Generate coverage report
npm run clean # Clean build artifacts
# Deployment
npm run node # Start local blockchain
npm run deploy:localhost # Deploy locally
npm run deploy:sepolia # Deploy to Sepolia testnet
npm run deploy:mainnet # Deploy to mainnet
# Verification
npm run verify # Verify on Etherscan
# Gas Analysis
REPORT_GAS=true npm test # Run tests with gas reportingSolution: Check your internet connection. The Solidity compiler downloads from GitHub.
Solution: Ensure your wallet has enough ETH for deployment.
Solution: Reset your account in MetaMask or wait for pending transactions.
Solution: Check hardhat.config.js network configuration and .env variables.
Solution: Increase timeout in hardhat.config.js:
mocha: { timeout: 60000 }- ✅ Run tests locally to verify everything works
- ✅ Deploy to local hardhat node for experimentation
- ✅ Deploy to Sepolia testnet for public testing
- ✅ Verify contracts on Etherscan
- ✅ Integrate with frontend application
- ✅ Conduct security audit
- ✅ Deploy to mainnet
- ERC-8004 Spec: https://eips.ethereum.org/EIPS/eip-8004
- Documentation: See
ERC8004_INTEGRATION.md - Architecture: See
NETWORK_DESIGN_BREAKDOWN.md - Test Guide: See
test/README.md - Hardhat Docs: https://hardhat.org/
- OpenZeppelin: https://docs.openzeppelin.com/
- Use
.onlyto run single test:it.only("Should...", ...) - Use
--grepto filter tests:npx hardhat test --grep "register" - Enable verbose logging:
npx hardhat test --verbose - Generate detailed gas report:
REPORT_GAS=true npm test > gas-report.txt
When you run npm test locally, you should see:
IdentityRegistry
Deployment (2 tests)
Agent Registration (6 tests)
Agent URI Management (5 tests)
Agent Deactivation (3 tests)
NFT Transfer (4 tests)
Edge Cases (4 tests)
✅ 24 passing
ReputationRegistry
Deployment (3 tests)
Posting Feedback (8 tests)
Reputation Score Calculation (5 tests)
Feedback Retrieval (4 tests)
Dispute Resolution (5 tests)
Access Control (3 tests)
Edge Cases (3 tests)
✅ 31 passing
ValidationRegistry
Deployment (2 tests)
Request Validation (4 tests)
Submit Staked Validation (5 tests)
Submit TEE Validation (3 tests)
Submit ZK Proof Validation (2 tests)
Finalize Validation (4 tests)
Dispute Validation (2 tests)
Resolve Dispute (4 tests)
Validation Success Rate (2 tests)
Access Control (2 tests)
✅ 30 passing
Total: 85+ passing tests
Time: ~5-10 seconds
Everything is set up and ready to go. Just run these commands on your local machine:
npm install
npm run compile
npm testHappy coding! 🚀