Smart contract to demonstrate peer to peer energy trading. We are using this as our starting point. It was a project done for hackathon on hyperledger and we are changing it to demonstrate peer to peer energy trading. Following changes have been made:
Allow chain code deployer to specify the commission that will be charged by the exchange smart contract from producers.
Exchange account (grid maintainer) is initialized at time of deploy.
A method to register a new meter is provided with the rate at which it is ready to sell/buy energy.
A method to delete existing meter is provided.
Data on meter id, meter name, reported kwh and account balance is stored in a table.
During settlement all the rows in the table are considered unlike hardcoded meter ids from 1 to 10 in original chain code implementation. Also, it matches buyers with sellers based on the rate and transfers account balance accordingly.
Additional query methods are provided to give meter information and exchange account balance.