Blockchain Enabled Distributed Demand Side Management in Community Energy System With Smart Homes

Existing work in energy demand side management focuses on the interaction between the utility grid and consumers. However, the previous technique is not focused on energy trading in local community of a renewable energy generation, distributed demand side management and not suitable for real-time environment. This paper presents a distributed demand side management system among multiple homes in community microgrid, with the integration of the internet of things smart meter and in the presence of renewable energy sources. The proposed energy consumption game is formulated for minimizing the cost of electricity in the individual home and the total cost of energy consumption in the whole community. The smart home users are playing game by optimizing their own daily energy consumption of appliances. The multiple participants include the self renewable generation of users, shared community microgrid and optional utility company. Each participant applies its best strategy to minimize energy consumption cost and users can maintain their own privacy of energy consumption. Moreover, the proposed scheme is distributed on blockchain, which provides a trusted communication medium between the participants. It enforces the autonomous monitoring of smart appliances and the billing of electricity consumption via smart contracts. Solidity smart contract is deployed to facilitate the execution of transactions without the involvement of third party in the smart community. Comparison of the results show that the proposed approach minimizes the total cost of energy consumption as well as each user’s energy consumption cost.


I. INTRODUCTION
The energy demand is increased steadily over the coming years. This energy demand driven from humans, industries, agriculture and electric vehicles is expected the growth will be increased in the order of 40% by the year 2030. This demand relies on increased energy to strengthen the human lifestyle, the emergence of electric vehicles as the primary means of transportation and machines will facilitate the process of automation. In the conventional power system, electricity is generated from fossil fuels [1] and accelerates global warming (environmental issue [2]). This conventional The associate editor coordinating the review of this manuscript and approving it for publication was Shuaihu Li . system has reduced flexibility and will hardly adapt to demand growth.
The problem solved to bring the energy generation close to the home by sustainable renewable energy resources (RES) [3]. An increased proportion of the renewable energy system will mitigate the environmental problem and change the consumer oriented market to the prosumer oriented market. Microgrid serves one user with its generation and demand. The emerging community microgrid provides the energy to multiple users [4]. Also, generate green energy in community microgrid with solar, wind with energy storage devices. When the demand is not fulfilled in a local generation, then bought the energy from the utility grid. This is worked with the grid-connected and stand-alone system.
In community microgrid, this provides the electricity in time of power outages, strengthen the central grid to function better, enhance community economics by reducing the electricity rates and improve the environment by renewable energy mix [5].
In the past, most of the work done on the electricity generation side and consumer loads are not manageable. The flat rate pricing will not motivate consumers to schedule the appliances and electricity usage for cost minimization. The flow of electricity and dataflow (information) are in bidirectional in smart grid (SG). The dataflow between homes and utility grid have manage with optimization at each consumer and improve the entire system via peak reduction [6]. Actually, it is impractical to ask consumer to optimize the schedule of appliances neither they are system operator nor economist. For this reason, need a fully automated load management system is required for consumers to take the benefits with scheduling the smart appliances. The energy management system is essential part of the SG that consumers use to manage electricity. The technical and economic constraints consider for best schedule of smart appliances. Community microgrid provide an opportunity for small scale distributed RES to trade energy locally. The realization of microgrid markets necessitate safe and smart information system for their appropriate operation [7]. Now industry 4.0 1 automate the whole system with integration of internet of things (IoTs,) blockchain, machine learning and data management with cyber physical system [8]. The complete power system is fully automated, secure and smart. Recently, IoTs scope is expanded with the variety of applications such as power system, smart home, health care, smart shopping and smart agriculture etc. The different types of IoTs devices provide the different services related to sensing, measurement, monitoring and controlling tasks. The IoTs are generating a lot of data on the Internet. For this, users need the distributed, lightweight, scalable solutions to secure from cyber attacks, security, privacy, reliable and cheap system [9]. Blockchain technology is used for secure communication to handle the data in distributed and secure way. Blockchain technology is used to implement various policies to protect consumer privacy and limit unauthorized operations in a decentralized environment [10]- [12].
A price incentive non cooperative game theoretic model is proposed for energy storage system without relaying on a central entity to achieve decentralized scheduling [13] and state machine driven smart contract is used for P2P trading. In [14], an efficient distributed system through P2P information exchange in market by non cooperative game using smart contracts. In [15], decentralized management of demand response programs in energy system using Ethereum smart contracts to enforce the rewards or penalties for prosumers and balancing the energy demand and production. Blockchain based energy internet distributed energy trading scheme is proposed to achieves the match of transactions under the premise of privacy-protecting [16]. In a community of smart building using blockchain technology, the energy management algorithm is decentralized, which enabled the secure communication medium between users and provide the monitoring and billing of electricity via smart contracts [17]. In [18], a distributed demand side management scheme is proposed using blockchain technology to facilitate P2P transactions and to maximize the payoff utility of individual participant and the whole residential system. In [19], used the centralized optimization approach to schedule the appliances in multiple homes. This approach provide the issue of home users privacy leakage in community microgrid because all users home appliances are controlled from community controller and share the information of loads consumption to violate their privacy. A third party or someone figure out a users living pattern, habits of energy consumption, behaviours and activities by sniffing the users information may also incur additional risks, e.g., burglary.
In this work, a game theoretic mathematical model is proposed to schedule the appliances of an individual home in a smart community based on electricity price and to improve the participant's privacy. The domestic users, being part of the smart community market, are benefiting from the reduced cost. The main principle is that the renewable energy produced is consumed locally in the community microgrid and transactions are executed on blockchain without the need of a central control entity. The proposed approach provides lower cost of electricity to the users and increases the flexibility in the local community market. Domestic user's behavior towards community goals (cost minimization) is managed by game theory. Ethereum smart contracts are used for autonomous monitoring, billing, exchange of energy and to handle the communication between participants in a distributed way. The smart contract code is written in solidity on Remix IDE. The nomenclature are provided in • A mathematical model is proposed to schedule the appliances in a smart community on basis of electricity price.
• The blockchain approach address the problem of decentralized energy and exchange the energy in a distributed (exchange between the participants) way.
• Smart contract are deployed for the monitoring the energy exchange and transactions settlement in the electricity trading system. The organization of this paper is as follows. The methodology for community microgrid appliances scheduling for multiple domestic prosumers/ consumers is described in section II. The energy consumption game is formulated in III. A proposed solutions are presented in section IV. Blockchain technology for energy management and appliances scheduling VOLUME 8, 2020 is presented in V. The case study and simulation results are shown in section VI. Conclusion is given in section VII.

II. METHODOLOGY
Energy management is a key objective in this paper to minimize the electricity cost by appliance scheduling using dynamic pricing schemes. The proposed framework using blockchain technology for the smart community energy systems is shown in Figure 1. Two types of controllers are used in smart community which are community controller and local home energy consumption scheduler (HECS) for each home in community. The community controller is used to exchange the pricing signal, available electricity in community microgrid and electricity purchase or sell to utility grid; balance the supply and demand in a smart community. Internet of thing smart meters (IoTs) are used as HECS to exchange the information between market participants i.e., consumers/prosumers, community microgrid and the utility grid. These IoT-SMs are used to control the information in bidirectional, control the home appliances and act as control centre in distributed market. Consumers share their energy consumption profile to the energy provider and maintained the privacy. The non cooperative game is proposed for appliance scheduling of each users home maintaining the users privacy.
Suppose, there are N number of homes/users in a community with different types of energy resources and some of them are prosumers. Some of users home is equipped with rooftop PV system with local generation. Each user has a smart IoT meter and smart IoTs appliances as per end user requirements. The user communicates IoTs appliances, user smart meter, community microgrid and utility grid via advanced metering infrastructure. Different types of smart appliances A ∈ A m,nm are operating in each home. Each home in a community has different appliances set A m,nm and pricing signal for electricity purchasing from community microgrid and utility grid. Each home has different willing time slot for appliances operation. All the information of user is private at HECS controller.

A. ENERGY RESOURCES
There are many kinds of sources available to generate energy to fulfil the requirement of consumers. The proposed energy system with self renewable generation from rooftop solar, wind, etc., of multiple users is called prosumers. Sometimes, energy is not fully utilized so surplus energy can share with neighbours or in the absence of self renewable generation from rooftop solar or high energy demand, then prosumer becomes a consumer. The consumers buy the energy from community microgrid or from utility grid. Energy is generated from solar, wind with energy storage etc., in community microgrid and provides to multiple users. The purpose is to fulfilled the energy demand locally in time of power outages, strengthen the central grid to function better, enhance community economics by reducing the electricity rates and improve the environment by renewable energy mix. Energy bought from utility grid for continuous availability for users in the absence of local generation.

B. CLASSIFICATION OF SMART APPLIANCES
As potential users of smart appliances have diversified in houses such as washing machine, boilers, dish washer, refrigerators, TVs, cooling & heating devices, and lighting apparatus [20], [21], perform the tasks for user accessibility. There are two major types of appliances are categorized below: The shiftable appliances are scheduled and controlled by energy management system over scheduling periods (T = 24). These appliances are scheduled from one time slot to other time slot in order to reduce the electricity bill. Shiftable appliances have a specific energy consumption load profile, in which the assured consumption cycle is flexible delays. The washing machine, vacuum cleaner, dishwasher and dryer etc., are the example of shiftable appliances.
Suppose, the set of manageable appliances is denoted as A m,n and a m = 1, . . . , A m,n for n ∈ N for each user.
The energy consumption of non shiftable appliance is constant during the operation period t ∈ T . Non shiftable appliances cannot be shifted to off peak hours for scheduling and reducing the cost. Such as power consumption profiles of electrical appliances such as lights, fans, refrigerators and televisions etc. Let a set of non shiftable appliances of user n ∈ N identified as In context of community microgrid, community owned electricity is generated from RES (solar, wind etc.). The aspiration of the optimization model is to schedule the limited resource of energy for the operation of appliances based on their period preference and cost of electricity. Appliances are operating based on 24-hours ahead time of use (TOU) electricity tariff. Here, P n,t is the total individual power consumption profile of user n ∈ N in t ∈ T time slot.
In community of N users, P T is the total combined power profile of all users in community. Let denote P n,t be the power profile of user n ∈ N at time t ∈ T , then Each user has own energy consumption schedule to reduce the bill and different demand peaks in a different time slots in day. Aggregated power profile are used to determine the peak-to-average (PAR) ratio [22]. This represents the shape characteristic of all demand of whole system. PAR is defined in equation (5). For this, first calculate the peak and average load levels as Pricing signal got from community microgrid. The utility grid are optional in our work. The amount of electricity to import and export at community level. Dynamic pricing scheme is used for electricity purchase from community grid. Its assumed, electricity pricing are known and cannot be changed after announced. These prices are based on flat rate, TOU, critical peak pricing (CPP) or real time pricing (RTP). The consumers are free to select the pricing scheme. The cost of same load may different at different time slot in a day. The electricity is cheap in day time in community microgrid and expensive to purchase from utility grid and vice versa in night time. The price of energy depend on the energy consumed and time of utilization of energy in a day.
where C n,t E is the tariff of electricity, R sa and E ba are decision variable to check the availability of renewable energy and energy storage in the community microgrid. C R and C B are electricity price from the community microgrid and C G is electricity purchased from utility grid.

D. PROBLEM FORMULATION
The objective function minimize the operational cost of the appliances in community and individual user. The users in community give the preferences in terms of their idles VOLUME 8, 2020 operating modes. The objective function in equation (7) and constraints are formulated in equation (8)(9)(10)(11)(12)(13).
where N represents the total number of users, where T represents the time, L represents the types of loads and A is the total number of appliances in smart community, α n,t la is decision variable for appliances scheduling, P n,t la is the power profile of domestic load appliances with respect to time t and C n,t E is the cost of electricity with respect to time t. In the second part of objective function, β n,t R is decision variable for renewable energy, G n,t R is self generated energy from renewable energy resources and C n,t R is cost self generated energy in time slot t. In the third part of objective function, γ n,t C is decision variable for energy storage, S n,t S is electricity storage at time t and C n,t C is electricity storage cost at time t.

1) DECISION VARIABLE
The constraint C 1 is decision variable of appliance ON and OFF. When decision variable is 1, appliance is ON and 0 for appliance OFF. The constraint C 2 is decision variable of user for self generation energy. When β n,t R = 1, user is a prosumer and β n,t R = 0 for user is a consumer. The consumer buy the energy from community microgrid or from utility grid. When γ n,t C = 1 energy storage is available to store energy and γ n,t C = 0 the energy battery is not available.
The power balance equation is presented in equation (9) for house hold energy system. This equation justify the power balance equation for user. P n,t + γ n,t C S n,t C are energy consumption demand profile and battery charging load prifile are equal to available power source from power grid P n,t G , community microgrid P n,t C , self generated energy from renewable resources G n,t R and discharing the energy storage battery

3) OPERATION PERIOD PREFERENCE
The binary matrix is used for the willing factor of appliances operation. This will provide the willing time slot W n,t la to operate the appliances a during t time slot. Therefore, home user want to operate any appliance more during a day, replace it by more appliances. These appliances operate based on operation period preference.

4) APPLIANCES SEQUENCE PRIORITY
The appliance can start their operation when an other appliance to complete the operation cycle. A dryer machine will not start unless the washing machine has finished its operation cycle. S i is the group of these kind of loads. Decision variable select single appliances from each group in each time slot.

5) APPLIANCES TASK COMPLETION
The smart appliances power consumption and operation duration is mandatory to know for power profile calculation. Different operation duration of different appliances in domestic load. t la is the operation time of ath appliances in T time slot in C 7 . α n,t la is decision variable to turn ON or OFF of smart appliances. The constraint C 7 and C 8 are continuous time to accomplished the task and its has to remain ON at time T , until it finished the task. It give the start time and end time of appliances. For example, if washing machine start operating, then it operate continuously till the final allocated time slot. C 8 is formulated for continuous operation of specific appliances in required time slot. ts is the starting time of appliances.
6) PEAK CLIPPING AND VALLEY FILING C 9 is valley filling. The constraints C 10 is peak clipping and this is the reduction of energy consumption loads during the peak demand. This constraint assure the peak demand after scheduling is less than or equal to the initial peak value P max .
l a α n,t la P t la ≥ P min ∀t ∈ T C 10 : l a α n,t la P t la ≤ P max ∀t ∈ T The objective function in equation (7) and constraints are linear in this optimization problem. This problem is solved in a centralized fashion using branch and bound algorithm and give the unique solution. This minimize the cost of users in whole community system. Recall that for multiple optimal solution of users in next section.

III. ENERGY CONSUMPTION GAME
In equation (7), to obtain an optimal solution of users and their schedules using the centralized optimization approach to solve the problem by incorporating the constraints from equation (8)(9)(10)(11)(12)(13). This centralized optimization problem is based on aggregated load of whole community. The users privacy leakage is the one of main problem in centralized approach and users share all the information with the central controller. Due to these problems, solving the objective function in distributed way at energy consumption users using its HECS. Use game theoretic approach, to exchange minimal information between HECS and energy sources. The objective is to use the HECS function to arrange domestic energy consumption based on the individual needs of consumers. It is also important to ensure that users are actually encouraged to use HECS features and implement it to reduce costs. The main focus in this work is energy cost minimization problem of individual user without privacy leakage. Each user billing cost depend on the offered billing pricing, available energy resources and consumption vector of shiftable appliances in T time slot. Each user optimize their own energy schedule to minimize the cost. A non cooperative game is modeled between the users in a community. All the users in smart community microgrid are players and N is a set of players. Each game among users for energy consumption is concerned about three component as • Players: All the registered users in smart community microgrid and N are set of players.
• Strategies: Each user n ∈ N selects its energy consumption scheduling to maximize its payoff • Payoffs: P n (P n , P −n ) for each user n maximize its payoff by minimizing its energy consumption cost bounded by constraints from equation (8-13) In game theory model, payoff defined by players own energy consumption profile. Each player want to maximize own payoffs and aggregated power profile P T is broken into the power consumption schedule of nth user is P n,t la and the other users in community is P −n,t la to minimize the cost. γ n,t C = 0 in our case. P n (P n , P −n ) = t∈T l∈L a∈A α n,t la C n,t E (P n,t la + P −n,t la ) In a non cooperative game, Nash equilibrium is the solution of game for two or more players where none of the player can increase his utility by deviating the point. If the energy consumption game is at unique Nash equilibrium, none of the player can increase his utility by deviating from the energy consumption schedule (P * n , ∀n ∈ N ). The strict Nash equilibrium exist for energy consumptions players if and only if equation (15) is satisfied. This Nash equilibiurm is the solution of cost minimization problem in (7). P n (P * n ; P * −n ) ≥ P n (P n ; P * −n ) ∀n ∈ N (15)

IV. DISTRIBUTED ALGORITHMS
The users are willing to cooperate and allow the HECS to schedule the appliance to pay less. The energy consumption game Nash equilibrium among the users is same as the optimal solution of problem (7) with linear constraint. Iterative approach to minimize the individual home electricity cost using the appliances scheduling in a community of N home users. Appliances scheduling and market clearing for one day using iterative approach. In this section, proposed an algorithm to implement at each home energy scheduling to attain the Nash equilibrium and obtain the scheduling vector for appliances scheduling. In this paper, two algorithms are used for energy trading and appliances scheduling in community. Algorithm 1 is used to update the energy availability, pricing to consumers and update the load vector P T . Algorithm 2 is used in player end for appliances end to update the scheduling vector.

Algorithm 1 Energy Exchange Algorithm
1: Begin 2: Send the information about availability the resources to consumers 3: Send the pricing signal to each user n 4: Get the initial schedule from users/consumers, 5: Calculate the aggregated energy load P t of N users, 6: Repeat 7: for no user changes their schedule Do 8: Single user n to run algorithm 2 9: Update and broadcast the load vector P t 10: end 11: end Algorithm 2 HECS for Each User n ∈ N 1: N is number of users, P n is energy consumption vector of nth user and P −n is other users consumption vector 2: Randomly initialize P n and P −n , 3: Repeat 4: for each n ∈ N Do 5: Solve the optimization problem (7) using Branch and bound algorithm 6: 7: Update P n schedule. 8: Announce schedule P n to the 9: other home energy schedule units across the community. 10: end 11: end 12: Update P −n accordingly. 13: end 14: Until no HECS unit announces any new schedule. 15: end

V. BLOCKCHAIN IMPLEMENTATION FOR ENERGY MANAGEMENT AND APPLIANCES SCHEDULING
The energy market generally leads to more flexible price variations, a more diverse energy scheduling, a more frequent energy trade and the liquidation of this energy transactions. Each user in proposed system model is abled to maximize his utilities through information exchange and transactions settlement in the electricity trading system via smart contracts. This system does not optimize the scheduling and electricity trading directly. For this, create the Community Blockchain Trading Chain (CBTC) which is used for trading the electricity in community microgrid and make the settlement of transactions. This is also used to store the appliance scheduling interval on blockchain or Off blockchain to operate where prices of electricity is low. Blockchain technology stores the data of all nodes, i.e., energy generated from RES, on-peak hours, off-peak hours, load demand and electricity tariff.
The domestic users are interlinked with energy management smart controller. In Figure 1, the purple line indicates the information flow (money, dispatch etc.) and black line shows the electricity flows in smart community. Each prosumer/ consumer has its own HECS (IoTs smart meter) for information exchange in community microgrid. HECS interacts with users, energy providers, collects information from smart appliances and operate automatically. This controller is used to manage the electricity demand to schedule the manageable appliances loads. This helps to optimize the local energy market in P2P manner and make the pricing agreement with community microgrid or utility. The users directly purchase the electricity from producers or energy providers (community microgrid or utility) and smart contract handles the process with predefined negotiation rules. The smart contract checks the availability of required electricity and also check the prices of electricity automatically. The smart contracts are immutable is the advantage in proposed system. Firstly, define the agrement using smart contracts, then send the money to the predefined address that work as escrow account. The electricity process is takes place after this process. The IoT-SMs control the flow of energy from producers and consumers and also control the consumer domestic smart appliances. Finally, implemented blockchain technology which is suitable for the efficiency of the proposed management approach. The advantage of our proposed approach fellows as i) it distributed the energy in a decentralized way for the community ii) it transmit the transaction peer to peer iii) it reduce the cost and improve the security iv) it provides the traceability of electricity usage which provide the facility to the supervision of the transaction v) The smart contract automatically executes without the interaction of the third party.

A. OPTIMUM SCHEDULING AND COST BENEFITS
Matlab is used to implementing the proposed scheduling in centralized and distributed coordination scenario. The objective function and incorporating all constraints is solved and attain the optimal scheduling. In this work, a day of 24 hours is divided in 96 time slots and one time slot interval is equal to 15 minutes. Total time slots are calculating by 24*60/15=96. The time is start from mid night 12 AM.
The price of energy is the input parameter used to take the decision for appliances scheduling. Dynamic pricing scheme is used to trade the energy from community microgrid and utility grid. The cost of same load may different at different time slot in a day. The electricity is cheap in day time and expensive to purchase from utility grid and vice versa in night time. The price of energy depend on the energy consumed and time of utilization of energy in a day. In this work, selection of energy tariff depend on the equation (6) basis on available energy sources and cost of electricity are shown in Figures 2-3. The energy tariff has been taken in CNY/kWh for 24 hours and CNY is the Chinese yuan. Each home has different willing time slots for appliances operation is an other parameter to take decision. This willing time slot depend on the preference of appliance operation basis on equation (13). The manageable appliances shift the operation time slot from peak demand time to off peak demand to minimize the energy cost. The energy consumption profile of shiftable appliances are given in Table 2. The energy consumption profile data of shiftable appliances and non shift appliance are taken from [20], [21], [23] which are used for appliances scheduling of individual participant in community microgrid. Figures 2 and 3 illustrate the optimal energy management of smart appliances. In Figure 2, only shows the shiftable appliances scheduling results. The results differentiate in terms of demand graphs between the optimal energy management of our scenario.   Energy consumption has increased in the time slot where electricity prices are low and renewable energy is available. This has led to the peak time of energy consumption has shifted and also reduces electricity consumption prices of consumers. The optimal scheduling of whole single home appliances load is depicts in Figure 3 where load of all shiftable and non shiftable appliances. Increase the utilization of energy in case of less price and availability of renewable energy.
The shiftable smart appliances pattern are depicts in Figure 4. This pattern show the scheduling of individual shiftable appliance. These smart appliances are shifted in day time at the time slot, when renewable energy is available and electricity tariff is low. Appliances sequence constraint in equation (11) is satisfied. Dryer operate after finishing the task of washing machine as shows in Figure 4. The different sources of electricity are available in our proposed model. Rooftop PV solar panel of 2kW is considered to generate electricity. The solar PV generation work in day time depending on the solar radiation and temperature. The solar energy generation profile is given in [24]. In Figure 5, 2kW power generation profile is plotted for single home which varies from 0 to 1.85kW.  Figure 6 shows the net optimal energy demand and energy import from community microgrid or utility grid. The local energy generation reduces the energy import to minimize the electricity bill. The appliance scheduling pattern are same as discussed in previous but final demand curve is different due the effect of power supply by local generation and decrease the net demand. Optimum and non optimum electricity bill of all users are shown in Figure 7 for smart community. The each home user pay the less electricity bill to the community microgrid or utility grid when HECS is enabled in the smart meter. Therefore, participants would be pleased to take part in the proposed energy demand management system.

B. IMPLEMENTATION OF BLOCKCHAIN TECHNOLOGY
Each user in proposed system model is abled to maximize his utilities through information exchange in the electricity trading system. This system does not optimize the scheduling and electricity trading directly. For this, create the CBTC which is used for trading the electricity in community microgrid and make the settlement of transactions. This is also used to store the appliance scheduling interval on blockchain or Off blockchain to operate where prices of electricity is low. For this, proposed system is implemented using Ethereum blockchain framework.
Remix is Ethereum integrated development environment (IDE). 2 This is a powerful open source tool for writing solidity contracts directly from the browser. Remix support is used in the browser and is written natively in JavaScript. In remix IDE, supports testing, debugging and deploying of smart contracts for different applications. The smart contracts are written in Solidity language. This language is object oriented and high level for writing the smart contracts. Smart contracts are predefined programmes which govern the behaviours of user account with in Ethereum state.
MetaMask, 3,4 is a tool which provide the bridge to visit the distributed web. This is used to run Ethereum dApps in browser without running full Ethereum node. MetaMask providing user interface to manage the identities and provide the secure transactions in main Ethereum network or some test network. In this work, install the MetaMask add-on in Chrome browser. First of all, create the wallet account for community grid, utility grid and home users for transactions as shown in Figure 8. The Ropsten Test network 5 is a testing network which run the same protocol as Ethereum and used for testing before deploying in main network. MetaMask Ether Faucet 6 is used to get the ETHs and send automatically in wallet address. The system component and description of proposed system is described below: 1) Accounts (Wallet address) are created for user using Metamask. In this work, two node are energy provider 6 https://faucet.metamask.io/  and other nodes are consumers. The local operator (community controller) to assign accounts to each users as new registration for energy provider or energy consumers. Blockchain network retain the copy of ledger and participate in consensus process. 2) Users can create own available energy and price; send to P2P market for trading energy. Other could see it own trading panel. 3) Users could take offer by invoking the function buyenergy() basis on lowest price. After this, transaction is completed. The information of recent block and transaction is updated in blockchain network system. 4) Dapp is a front end application that allows a smart home in a community to interact with blockchain. This facilitating the automated control of distributed system in community for trading and monitoring. 5) Ledger is decentralized database which store the shared data including energy data, pricing for all homes. 6) Smart contracts are auto executed based on ledger data. This make the energy and financial transactions between energy provider and energy consumers. This send the control signals to toggle automatically ON/OFF of appliances to participate in smart community. The main purpose of deploying the smart contract system for energy trading could be possible between the community microgrid and utility in efficient way without the involvement of third party. The smart IoTs appliances store the data in ledger. The functions,  events, state variable and modifiers are main element in smart contracts. The whole trading process and scheduling is done by system itself with a little manual intervention. The operation cost of system is lower, information is traceable and secure. Etherscan 7 is a Block Explorer for Ethereum blockchain which is used to verify the every transaction information is stored in this work. This is allowed the users to lookup, confirm and validate the transactions in Ethereum blockchain. Figure 9 shows the smart contract running in Ethereum network, the transactions flow and how Metamask signs the transactions using owner private key. Figure 10 is a blockchain transaction. This transaction tells the information about level of difficulty for mining, transaction hash function, gas limit used for the transaction to run on Ethereum. The nonce ensure to store the information permanently in blockchain. The specific transaction detail see in Etherscan. The proposed 7 https://etherscan.io/ smart community energy trading and appliances scheduling system is implemented in the form of smart contract on blockchain technology. The smart community trading algorithm is written in solidity and tested on Ethereum blockchain platform. Figure 11 shows the transactions record in Etherscan for contract creation, 8 in next two transactions give the permission to register energy providers and consumers in community market. Energy provider offer the energy price, quantity, timestamp and day and consumers buy the energy from seller on basis for energy price, quantity and time.

VII. CONCLUSION AND FUTURE DIRECTIONS
Distributed demand side management system among multiple home users in a community microgrid with the internet of things smart meter is proposed in this paper. The appliances are scheduled in the smart community by using game theory. The main advantage to use the game theory to reduce the cost of electricity of individual homes. Furthermore, the execution of smart contract which automatically communicates between the participants. However, the proposed scheme apply solidity smart contract is deployed for the settlement of transactions. The adaption of the blockchain technology, exchange the energy between the participants and create trust among the users or organizations. The presented results show that the total cost of energy consumption of the whole community as well as each user's individual cost is minimized, and the energy consumption profile is improved. In the future, compare the transaction cost of the blockchain technology using smart contract. Moreover, to design a framework which support the more scalability in terms of sharing the energy and reduce the cost. His research interests include the optimization of wireless communication systems, nonconvex optimization, resource allocation in cognitive radio networks, and approximation algorithms for mixed-integer programming in communication systems. He was a recipient of the NSERC CGS Scholarship. VOLUME 8, 2020