Research Article
A Secure and Efficient Energy Trading Model Using Blockchain for a 5G-Deployed Smart Community
Algorithm 4
Smart contract for energy trading.
Input: energy requested from EBEV; | Output: (1) ESEV gives energy to EBEV; (2) EBEV sends money to ESEV; | 1: function EnergyTrading() | 2: if(EBEV available balanceEV’s charging cost)then | 3: returnfalse; | 4: if(ESEV available energyEV’s requested energy)then | 5: returnfalse; | 6: if(EBEV storageamount of energy purchased)then | 7: returnfalse; | 8: else | 9: Subtract amount from EBEV’s account balance; | 10: Add amount to ESEV account balance; | 11: Store transaction; | 12: Subtract energy from storage of ESEV; | 13: Add energy to storage of EBEV; | 14: Store transaction; | 15 returnupdated information; |
|