SolarPay
Rooftop solar that sells its surplus to the neighbour by itself — a real panel and Arduino meter, rule-based agents, and one Monad transaction per trade.
- Role
- Gateway, agents, backend & web app
- Team
- Two-person team with Devang Gandhi (contracts, hardware)
- Stack
- Python
- Flask
- web3.py
- SQLite
- pyserial
- React
- Vite
- viem
- Solidity
- Foundry
- Monad
- Arduino
- pytest
01The problem
Rooftop solar in India often generates more power than the house uses in the afternoon. That surplus goes back to the grid, and the owner is paid months later at a price set by the electricity board — while the neighbour next door pays the full grid rate for power they need right now.
Peer-to-peer solar trading between neighbours has started to be permitted, but there was no system that does it automatically, settles instantly, and proves the power was actually solar.
Built for — Rooftop solar owners (sellers), their neighbours (buyers), and the grid company that should still receive its fee.
- 01Solar panelReal panel; torch on → watts rise
- 02Arduino meterReads panel voltage on A0, rings a buzzer on settlement
- 03Python gatewaySerial reader, Wh accumulator, 15 s market slots, HTTP API
- 04Seller & buyer agentsRule-based offers; buyer scores price 50 · supply 30 · distance 20
- 05SolarPay.sol on MonadrecordGeneration() then settle()
WEB APP
React + Vite, viem
Live panel, Agent Room replay, market, receipts, seller and buyer dashboards. Reads trades straight from the contract; rule changes are transactions from the user's own wallet.
ONE TRANSACTION SETTLES
- Seller paid
- Grid fee to DISCOM
- Green receipt + reading hash
- Built by me
- Teammate / hardware
02What I built
- Built the Python gateway: Arduino serial reader and buzzer link, watt-hour accumulator, 15-second market slots, accounts, and the HTTP API the web app consumes.
- Designed the deterministic seller and buyer agents and their scoring tools — price, supply reliability, and distance — with every decision explained in plain language.
- Wrote the web3.py chain layer with a LiveChain for real Monad transactions and a SimulatedChain that enforces the same settle() rules in memory, so gateway bugs surface before they cost gas.
- Built the React + Vite web app: live panel view, the Agent Room replay, market, green receipts, and separate seller and buyer dashboards where changing a rule is an on-chain transaction from the user's wallet.
03Key decisions
- D1
No LLM in the money path
The agents are deterministic and rule-based. People set limits once ("don't sell below ₹X", "only within 2 km"); the agents act inside those limits and the contract enforces them, so even a buggy agent cannot overpay, double-sell a reading, or sell power the meter never recorded.
- D2
Explainable buyer decisions
The buyer agent scores eligible offers as 50% price, 30% supply reliability, and 20% proximity. Every offer ends up picked, beaten (with its score), or skipped (with the rule that excluded it), so the full negotiation can be replayed in the UI.
- D3
One transaction settles everything
settle() pays the seller, splits the grid company's fee, and emits a green receipt tied to the meter-reading hash — no reconciliation step and no way to reuse a reading.
- D4
Simulate before you spend
A practice mode runs the whole system with a simulated panel and an in-memory contract, so anyone can try it without hardware or a wallet, and the gateway is tested against the same rules as the real contract.
04By the numbers
- Python tests
- 50
- Contract tests
- 12
- Market slot
- 15 s
- Networks
- Monad mainnet + testnet
Figures taken directly from the repository.
05What's real vs. simulated
- Real: the solar panel, Arduino readings, the buzzer, agent decisions, every transaction and receipt, and accounts, wallets and rules stored on-chain.
- Simulated: five neighbour rooftops (real wallets registered on Monad whose meters follow the real panel's light), physical grid delivery, and identity/electricity-board verification.
- Watts are derived from the panel's voltage — a proxy, not calibrated metering.
Want to talk through how this was built?