This guide walks you through testing the complete PowerGrid Network MVP.
-
Substrate Node Running
~/.local/bin/substrate-contracts-node --dev --tmp --rpc-external --rpc-cors all -
Contracts Deployed
- All 4 contracts should be deployed
- Addresses configured in
backend/.env
-
Tapo Device
- Device powered on and connected to WiFi
- IP address configured in
backend/.env
Run the full system check:
./scripts/demo-full-flow.shThis will verify:
- ✅ Node is running
- ✅ Contracts are deployed
- ✅ Device is registered
- ✅ Tapo device is connected
In a terminal, start the oracle service:
cd backend
source venv/bin/activate
python src/oracle_service.pyThe oracle will:
- Connect to Tapo device
- Connect to blockchain
- Check device registration
- Start monitoring every 30 seconds
In another terminal, create a test event:
cd backend
source venv/bin/activate
python scripts/create_test_event.pyOr use the bash script:
./scripts/create-grid-event.sh DemandResponse 60 750000000000000000 100This creates:
- Event Type: DemandResponse
- Duration: 60 minutes
- Compensation: 0.75 tokens per kWh
- Target: 100 kW reduction
The oracle will automatically:
- Detect the new grid event (within 30 seconds)
- Check current energy consumption
- Participate if energy > 0
- Report energy contribution
- Earn token rewards
Watch the logs:
tail -f backend/logs/oracle.logCheck your token balance and participation:
cd backend
source venv/bin/activate
python scripts/check-rewards.pyFor a quick demo, run everything in sequence:
# Terminal 1: Node (if not running)
~/.local/bin/substrate-contracts-node --dev --tmp --rpc-external
# Terminal 2: Full system check
./scripts/demo-full-flow.sh
# Terminal 3: Start oracle
cd backend && source venv/bin/activate && python src/oracle_service.py
# Terminal 4: Create event
cd backend && source venv/bin/activate && python scripts/create_test_event.py
# Terminal 5: Watch logs
tail -f backend/logs/oracle.log
# Terminal 6: Check rewards
cd backend && source venv/bin/activate && python scripts/check-rewards.py🚀 PowerGrid Oracle Service Starting...
✅ Configuration validated
✅ Tapo device connected
✅ Blockchain connected
✅ Device already registered
📊 Monitoring Iteration #1
⚡ Current Power: 0.00 W
📈 Today's Energy: 0.000 kWh
📢 Found 1 active event(s)
🎯 Event 1: DemandResponse
⚠️ No energy contribution to report yet
💰 PWGD Balance: 1000.0000 tokens
📊 Monitoring Iteration #5
⚡ Current Power: 150.50 W
📈 Today's Energy: 0.125 kWh
📢 Found 1 active event(s)
🎯 Event 1: DemandResponse
✅ Participated with 125 Wh
💰 PWGD Balance: 1000.0938 tokens
- Check that events are active:
python scripts/check-rewards.py - Verify oracle is connected: Check logs for connection errors
- Ensure node is running:
curl http://localhost:9944
- Check IP address in
backend/.env - Verify device is on and connected to WiFi
- Test connection:
python src/tapo_monitor.py
- Verify contracts are deployed:
./scripts/demo-full-flow.sh - Check contract addresses in
backend/.env - Ensure node is running
- Plug in a device to the Tapo smart plug
- Watch energy consumption in real-time
- See automatic participation in grid events
- Track token rewards as they accumulate
scripts/demo-full-flow.sh- Complete system checkscripts/create-grid-event.sh- Create events (bash)backend/scripts/create_test_event.py- Create events (Python)backend/scripts/check-rewards.py- Check token balance
For more details, see scripts/README.md.