{'fraction_non_alphanumeric': 0.021356519911736892, 'fraction_numerical': 0.003966586109067983, 'mean_word_length': 4.843284727551803, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Integration Of Smart Grid And Blockchain

— A majority of electricity consumed by humans comes from traditional power generators, that work on a centralised framework, distributing it through wires and grids. More than 80% of this electricity comes from fossil fuels, leading to large amounts of pollution, since it is carbon intensive. The distribution methods are inefficient as much energy is lost in transmission. This leads to it being expensive for the consumer, and makes them dependent on large corporations. A large percentage of the electricity bill goes towards paying off the investment in infrastructure needed to provide it. This model is clearly not sustainable. Furthermore, it is estimated that around 1.2 billion people live without access to safe electricity. This is primarily since electricity providers don’t deem building infrastructure for a remote or economically backward location as profitable enough, since they are unlikely to pay it back. Contrary to conventional system, our proposed framework will be focused at introducing the decentralised energy distribution and consumption using Blockchain. Many prior studies have been done to decentralise the energy distribution but due to security and trust scare the systems could not be fully adopted in the real setting. We take a look into the methodologies third parties can use to counter the security issues as well. However, by integrating blockchain into the existing smart grid architecture we open up the possibility of bypassing the tiring process of renewable certification, make a localised energy production a reality and detach the consumers from the dependency of central grid. To fully assimilate this environment with the end users we also discuss about the real time platform for prosumers and consumers to trade energy. At the end, we look at the costs, consumption and other attributes of three different community microgrids simulation based on the installation of PV, Storage and Load.


INTRODUCTION
The continuous use of the depleting fossil fuels has led to a large part of pollution caused by human activities. Additionally, they utilize a centralized framework to produce and distribute electricity. Transmission through wires to city sub-stations is an inefficient activity, and so is the subsequent conversion to a lower voltage. The consumer is also at the mercy of large corporations, in terms of high fee and bills. There is a single point of failure, that is if the city sub-station suffers from a failure, the entire city is affected with power outages. Remote locations are disregarded by companies as their rate of return does not compensate for the investment. In contrast to this, a framework that is decentralized would serve the consumer better. To this end we couple microgrids with blockchain to incentivize local energy production, through renewable resources, such as solar and wind. Microgrids would enable local participants to gain control of their energy needs. Consumers may turn into prosumers, and transfer energy within their community. Even if not used for replacing the current framework immediately, microgrids offer the potential to provide energy during power outages. Blockchain is an ideal technology for such a decentralized model, since it takes away the need for a third party to monitor consumption and energy transfers, its mechanisms such as smart contracts and its authentication methods provide secure ways to log transactions. It could also open up doors to a virtual currency for such energy transactions. We also evaluate the security of such a framework, in addition to the use of data analysis in order to optimize consumption and distribution

II. SCIENTIFIC RATIONALE
In the past few decades, traditional fossil fuel based frameworks have been questioned on some significant shortcomings, such as energy loss in distance transmission, harmful fossil fuel by-products, climate contamination as a result of it, which has led to an energy crisis. Additionally, a centralized framework does not benefit those who live in areas where it isn't profitable for energy companies to deliver energy. Countering these problems provides multiple reasons to prompt a study in this field. The use of sustainable power from assorted sources and improving the productivity of energy utilization are the two important considerations. In recent years, the smart grid concept which involves communication technology, interconnected power system, advanced control technology, and smart metering has been applied to improve the utilization of renewable energy sources (RESs) and relieve the energy crisis somehow. The concept of smart grid has been introduced as a new vision of conventional power grid that offers two-way energy and information exchange in order to figure out an efficient way of delivering, managing, and integrating green and renewable energy technologies [38].
The principle point of the system would be that the participants and components have the capacity: 1) to interact closely with one another; 2) to take decisions without the need of a third party; 3) to trade both energy and related data in numerous ways; 4) to access large-scale different types of distributed energy resources (DERs) seamlessly; 5) to adjust with both concentrated and dispersed fuel sources; 6) to handle energy supply and demand by means of energy sharing; and 7) to ensure flexible energy generation/selling and purchasing/consuming the energy. A lot of work has been done around the smart grid and its data, but little efforts have been shown to address the security and privacy aspect of the system. This is one of the major setbacks that is preventing the communities to accept the microgrid concept. A faulty and vulnerable security system exposes the participants to numerous problems ranging from power outage, low power latency due to external attacks. This problem becomes more concerning when microgrid connects hospitals and defense department in its web. Power outage at critical locations can make this technology skeptical among general public and government thus banishing all the funding and resources to the sector. Hence, security becomes a priority matter that supersedes all the developments taking placing in grid innovation. The deployment of the blockchain on smart grid can alleviate or eliminate almost all the security problems arising out of communication, transaction or any concern relating to data traversal. The blockchain-based data management also reduces the cost of data storage in the centralized system for utility operators. We are going to further explore this topic in the coming sections. Another matter of concern is mutual agreement. Blockchain is competent to keep track of transactions among participants but it cannot dictate the terms of transaction i.e., on what terms and conditions should there be a transfer of funds from one party to another. Ethereum [25] offers the solution to this problem. It was the first cryptocurrency to launch the concept of smart contract. Smart contract allows the transaction between two parties without worrying about post agreement trust issues. We are going to explore this further in the coming sections.

III. LITERATURE REVIEW
The literature review for this paper aims to cover all the smaller underlying components and concepts that make up our framework. We evaluate existing optimization and scheduling technologies of microgrids, in order to better understand how to make improvements to existing frameworks.

A. Smartgrids and Microgrids
Conventionally power has been based on a system where it is generated at and delivered henceforth from large and distant power plants. This is a centralized system. The conversion stations are near consumers, making this inefficient. A distributed system with small scale energy generators and distributors near the consumers is proven to be more sustainable. [8] Prete and Hobbs used game theory to analyze how a microgrid would work with market participants, and report that a microgrid run by prosumers and consumed within the community leads to economic and social benefits for the parties involved. [9] Furthermore, losses in transportation are reduced significantly by utilizing renewable resources available and close to the community, also making it less expensive. [10] Silvente et al. propose a rolling horizon approach to handle uncertainty associated with production and consumption of energy in microgrids. They combine this with Mixed Integer Linear Programming (MILP) that allows them to consider varying input parameters, thus accounting for variations from the nominal schedule. [11] Tinguang and Qian propose an energy management system based on cooperation of the system. It uses multi-grid connected microgrids (MGs) based active distribution system (ADS). The interaction between MGs and active distribution network (AND) is described by bi-level programming, and that amongst MGs by an innovative interactive energy game matrix (IEGM). [12] There also exists a multi-agent-based approach for the purpose of management and operation. Such a framework would allow one to add additional distributed grids and components without an overhaul of the existing smart grid. Coelho et al. mention that each component in a MG will be an agent and this would open up opportunities for Plug-in Electric Vehicles (PEVs). [13] A distributed energy resourcesconsumer adoption model (DER-CAM) based ICES model has been tested in Netherlands, and showed reductions in total energy costs and CO2 emissions. This model allows for surplus energy to be combined in a community energy exchange platform. This may be operated on peer-to-peer exchange or withy a cost-based model. Nevertheless, households can fulfil their deficit with this platform. [14] Ilic et al. propose an online marketplace's design and implementation for a smart grid community. [15] Gauging such demand also becomes crucial, so renewable resources may be better utilized. Simulations show that balancing user demand and consumption is more profitable than using traditional fossil fuel-based generation methods. This gap is widened for isolated microgrids, where users participating reduces total load and hence cost. [16] Block, Neumann, Weinhardt add to this by suggesting a combinatorial double auction mechanism. This takes into consideration the producers and consumers for pricing and allocation. Using multiple parameters, they maximize welfare for all involved. [17] However, the management of these grids needs to take into account that actors may be self-interested and transmission may be constrained. Continuous Double Action (CDA) based mechanism which manages congestion within the system, and deals with unforeseen demand spikes. [18] B. Blockchain We also study existing literature on blockchain, in order to evaluate its feasibility for integration with a smart grid. Blockchain is a technology that, although finding its initial wide-scale application in finance, can be utilised in a variety of cases to verify transactions. It removes the need for a third party and makes process distributed rather than centralised. [19] Even in cases of little, no or negative trust, blockchain has been shown to work. This is helpful since it allows decentralised systems to work in a variety of conditions. [20] It also does away with conflicts of interests and provides information symmetry for its participants. This increases the conviction that a central authority isn't needed to supervise transactions. [21] The characteristics and components of blockchain that make this possible are distributed smart ledgers, decentralised consensus mechanisms smart contracts and cryptographic security. However, it is important to mention that maintaining this ledger requires significant computational power. Proof-of work is a computationally expensive mechanism. [22] We therefore, might look towards a proof-of-identity mechanism that would be hash based. This is less computationally costly. The level of security this offers is significantly less than that by proof-of-work, and this remains a trade-off needed to be taken into account. [23]

C. Smartgrids and Blockchain
It is the combination of these two concepts, microgrids and blockchain, that we are focusing on here. Research in this field is still new and upcoming. Mihaylov et al. have come up with a decentralized currency that may be used to trade energy within a grid. The price of such a currency would be determined in the open market. The way this would stand out from current cryptocurrency such as bitcoin is that it would be produced when new energy is injected into the grid, thus doing away with the need for additional computer power. They claim this might also provide additional incentives for prosumers and consumers to balance out their production and consumption. [24] Another novel model that may be adapted is a Decentralized Carbon Emissions Trading Infrastructure (D-CETI). Kawasaki et al. propose trading carbon emissions amongst actors in the system. It is based on Bitcoin and Open Transactions, and the agents trading, remain anonymous. [25] Even Aitzhan and Svetinovic come up with a solution for decentralized trading in a smart grid and provide a proof-of-concept that uses blockchain, multi-signatures and anonymous encrypted streams. The participating traders are anonymous when negotiating prices and trading. Bitcoin is also a key enabler of Transactive Energy. Transactive energy refers to the use of a combination of economic and control techniques to improve grid reliability and efficiency. This coordinates the activity of increasing distributed energy resources. These systems work interactively with the grid and gives intelligent load, storage and generation sources.
[27] Pipattanasomporn et al. show how a neighborhood may utilize blockchain to exchange solar energy produced from photovoltaics, making a peer-to-peer marketplace. They utilize open source blockchain platforms such as Hyperledger, Ethereum and Corda. [28] Fabric is also an open-source system for deployment and operation of blockchains. Its modular consensus protocols can allow it to be used in tailor-made cases. [29] RESs are prone to sudden and unforeseen spikes in energy production, and this might not correspond to demand. Thus, to mitigate this, communication between producers and consumers is essential. Siano et al. propose a novel consensus protocol for P2P energy exchanges in the form of Proof of Energy. [30] IV. OBJECTIVES Considering the shortcomings listed for the current energy delivery model, our objectives centre around creating a more efficient and sustainable framework, while ensuring we leverage IOT to help consumers take control of their own energy needs. We propose 3 objectives we aim to achieve through this paper 1. Prompting a shift from non-renewable to renewable resources for energy production, and using microgrids as a tool to further this objective. A majority of inefficiencies of a centralised energy production system hinges on the use of nonrenewable resources such as fossil fuels. This leads to excess pollution and an unsustainable future. By using microgrids, the propensity for use of renewable resources for energy production increases considerably. Microgrids are distributed, and selfsufficient energy systems which aim to serve a small community or locality. The community is hence likely to use renewable resources widely or easily available to them such as solar, hydro etc. This also allows one to use other decentralised technologies in tandem with microgrids, in order to create smart solutions for energy production, delivery and consumption. We also deploy blockchain to further this objective, using it to aid in transfer of energy, by keeping track of transactions. 2. Optimising user consumption through data analysis of consumptions and energy distribution patterns.
Here we evaluate different methods to acquire data from the microgrid, such as cloud vs fog. This data and subsequent analysis on it would show the best way to provide and distribute energy amongst the households or loads in the network. This is something that can allow users to make consumption more efficient from their end. 3. Tackling security issues, with blockchain as a tool.
Microgrids for quite some times were considered with a shortcoming, and that was security issues.
Since transfer of energy could not involve a third party, there needed to be a secure, decentralised mechanism to keep a ledger of transactions.

V. IMPORTANCE OF OBJECTIVES
All the objectives discussed hold their own reasonings and merits to be included in this paper. This section will aim to enumerate them. 1. The first objective is arguably the most important, for multiple reasons. The ills of pollution due to the current energy production and delivery model have been highlighted in recent decades. Most countries around the world use a centralised model. This means energy is produced, generally by fossil fuels, at large centralised power plants, far from city centres. It is then transported over large distances. This leads to energy losses. It is then stepped down to a lower voltage at sub-stations near the city. This too leads to energy losses. Hence a shift towards a sustainable framework is needed. A microgrid solves the problem of large losses in transmission, since it is close to the community or loads that require electricity. Furthermore, it can be run on renewable resources available to the community and thus takes away the use of fossil fuels such as coal. This also empowers rural or disadvantaged communities. They can remove the need for a private energy provider by creating their own microgrid. They may also work either on their own or in tandem with other microgrids, since they are a decentralised technology. The use of blockchain is also important here. Having a third party or private company monitor energy flow in the grid and amongst houses defeats the purpose. Hence a decentralised technology such as blockchain would remove the need for an external third party. 2. There are also considerable losses due to user consumption habits. With the number of appliances and hence loads within a household increasing, it becomes difficult for a consumer to know which of them consumes how much electricity, and where they can save. Here we propose data analytics to make users aware of their patterns and present to them optimal energy consumption models. This may be integrated with smart meters that can show important information. Additionally, this analysis can allow the grid to determine optimal energy distribution based on past and predicted energy consumption patterns for a household, ensuring minimum wastage. The architecture as in [33] to go for the integration of IoT with cloud for the successful integration of cloud-based computing system in IoT. Fog provides IoT data processing and storage locally at IoT devices instead of sending them to the cloud with faster response and greater quality. Therefore, fog computing may be considered the best choice to enable IoT to provide efficient and secure services for many IoT users. Table 1 [34] gives an overview of how it could prove to be better and go on to solve various security and data analytics related issues. 3. The last objective aims at solving security concerns around a microgrid. Since blockchain is used, there is no need for a central authority. Blockchain has been shown to work in a low or even negative trust environment, securely. It has multiple entities, all maintaining a secure ledger. There are multiple aspects of blockchain which allow this. Smart contracts are part of blockchain and can't be modified, thus making them immutable. We also ensure trust and increase fault tolerance, thus making it less vulnerable to exploitation, cyberattacks and typical shortcomings of centralised frameworks.

VI. FRAMEWORK
Our framework is a two-layer architecture: Virtual Layer and Physical Layer. Physical layer is the on-ground wiring and connections through which electricity runs whereas the virtual layer is an interface or architecture for communication, data analysis, energy trading built on blockchain.

A. Physical Layer
Traditionally, all the houses have been connected to the central grid. In India, the grid runs through the following checkpoints, Central Power Station-> Sub-Station->Transformer->Consumer. These checkpoints facilitate AC/DC conversion and electricity propagation. This is a series connection and thus highly vulnerable to any faults. So, for example if a fault occurs at a central power station, all the subsequent checkpoints will face its ramifications. The central grid system also accounts for high power losses, up to 40% in India, which the final consumer has to pay. Taking these drawbacks into account we are proposing a physical system, partially controlled by virtual layer, that can decentralise the grid and cut the line losses. The new framework would also ensure that the central grid remains intact, capping any huge investment. Empirically, microgrid remains similar to central grid, one provided by government, but it connects decentralised energy sources and storage to the grid along with the community houses, which in turn helps the microgrid to operate in islandic mode when there is power outage in the area. This microgrid architecture also allows succinct and easy energy transaction between houses. The incoming connection from microgrid to the house is connected to the smart transactive meter, which is different from the one provided by the government. This meter displays all the information related to the energy produced by the household and the energy received from other households. We take enough energy from the main grid so as to fulfil the energy deficiency if it arises due to low sunny profile. In the current net metering system that was recently launched by the Indian Government, if a household produces more energy using PV than its requirement then the smart meter starts to rotate in an opposite direction indicating net supply. At the end of the month the consumer is supposed to pay the bill as given by the net reading (=Consumption-Supply Units)

B. Virtual Layer
Before we move onto virtual integration it is important for us to understand the basic functioning of blockchain and smart contracts.

B1. Blockchain
Blockchain is a decentralised cryptocurrency, which functions like any other currency except it is not regulated by a centralised authority like the Federal Reserve. On a technical note, it is a broadcasted block of ledger (A document containing accounting statements), where each ledger holds a specified number of entries (Alex pays $50 to Brian). To ensure that each transaction or entry is genuine, each entry is signed and verified using a digital signature of 256 bits. These signatures are secured and protected using RSA encryption so that no outsider can imitate them to list a wrong entry. Blocks are connected to each other using the hash keys, a cryptographic value which gives a unique identity to file or text, of previous blocks. This chain formation between these blocks anoints it with the name "Blockchain". As one may wonder, how do these blocks are actually formed? The block of ledger in this chain is not formed on its own. It is created by the so-called miners, who find a key, which when combined with the entries of ledger give a hash value consisting of a specific pattern. If the specific pattern is not found in the hash value, it is trashed and block formation fails. What if a participant adds a fraudulent transaction? Most Blockchain are built on a consensus protocol i.e., majority. So, if a member receives conflicting blocks, they wait for subsequent blocks to arrive. Whichever chain remains the longest is accepted by the member. The fraudulent chain can never outpace a valid chain unless the fraudster holds more than 50% of computational power. Now the question arises, who is responsible for creating the blocks in the microgrid network. As this is a private block, regular miners (People who create the blocks) are not allowed to do the job neither can we expect producers and consumers participating in the microgrid to be the miners. The latter option might give undue opportunity to some technical participants to mine the blocks and pass fraudulent transactions. To ensure that even if a certain participant holds more than 50% server power the fake chain should not suffice for long, a novel and ingenuous method has been proposed in this research snippet [35]. It proposes a cyclical introduction or creation of blocks, giving equal chance to each participant regardless of the server power she holds. Hence, even if some fraudster adds a wrong block the next participant can put in a right block. Suppose if there are m participants and the first node adds a false block. That block won't be validated until after all the remaining m-1 participants add their blocks. This goes on for subsequent blocks. The figure 3 below can give a clear picture of this practice. Although there are many other protocols to validate the transactions, we think that consensus protocol is best suited for Smart Grid. Our idea is in stark contrast with many researches where a diverse variety of validation protocols have been used to alleviate the latency cost associated with consensus protocol. We think it is quite irrelevant and less secure to use any other protocol but consensus because the anticipated traffic i.e., homes connected to the smart grid are not going to be that huge to make latency cost a matter of concern. But as far as the security is concerned, it is best to keep the system as decentralised as possible to make it robust against any external threats. That is why it is best to use consensus protocol. Before we move on to smart contract, it is best to summarise the security aspects addressed by blockchain: a. Authentication and trust: Since the data exchange procedure in a blockchain uses public-private signature scheme, the "Man in the middle"/ impersonator attacks are quite detectable. Since there is no third party to be trusted with data handling, the trust on the third party to act with integrity is no longer necessary and the access to sensitive information is easily avoided. b. Fault Tolerance: The working mechanism of a blockchain oriented mechanism allows the grid to gracefully handle the possible malicious behaviour of dishonest nodes. Since all the participating nodes retain a replica of the entire shared chain, every node has the capability to identify settings or measurement leakages and can easily mitigate them. The infrastructure recovery is quite rapid because the ledger is distributed in nature, thus it exists in various locations. This happens to be a crucial and significant attribute of distribution and transmission protection systems. c. Integrity and Immutability: The blockchain being a distributed leger, is resistant to tampering and censorship attempts. After intercepting a transaction message, there might an attacker trying to question the integrity by falsifying setting commands and other parameters. Due to the disagreement between the hash of the modified data and the hash inside the sender's digital signature, the content verification would fail and thus the attempt would never succeed. Altering the measurements on a block changes its hash-based identifiers therefore causing a dynamo effect dynamo effect on the cryptographic links between the blocks. In order to handle this, the attacker would have to either alter the headers of all the blocks that follow the block that's being attacked or make those alterations to at least 2/3 rd of the entire network for the consensus to succeed. Since both the ways seem to be highly demanding in terms of computational and communicational power, the system is shielded against false -data injection attacks [37].

B2. Smart Contract
This is a decentralised digital contract which allows a credible transaction based on certain pre-conditions without the requirement of any third party. It was first proposed by Nick Szabo in 1994. Its relevance came to light when Ethereum, most expensive cryptocurrency after bitcoin, decoupled the block ledgers and smart contracts and established latter on former. The Ethereum project introduced the idea of decoupling the contract layer from the blockchain layer, where the ledger itself is used by smart contracts that trigger transactions automatically when certain predefined conditions are met. These contracts are irreversible. As contracts are decentralised, it is practically impossible to flout the terms and conditions established by the contract. The mechanism of this contract is such that the concerned parties are told to lock in all or some of their assets, as mentioned in the contract, and when the conditions are met by some or all the parties, the contract triggers and the relevant transaction takes place. It is quite naive and colloquial to say this decentralised digital contract is a smart contract. It is as smart as the code embedded, laying down all the terms and conditions in it. To understand it more holistically let us take an example. Suppose Alex, identified by X public key, wants to sell the car at $20,000. He prepares the contract which says that anyone with a bid equal to or more than $20,000 for the car, identified with blockchain address (private key) XX, be given the access to its private key and then Alex signs that contract with his private signature. Now, Suppose Alice wants to buy the car, she would run into this contract by signing it with her own private key. This contract is then distributed to all the nodes of the blockchain which verify if Alex has the car and Alice has enough money to buy it. Once verified, as per the contract, Alex is transferred $20,000 from Alice and Alice receives the private key of the car. So, whatever smart contract contemplates it is completely based on the code planted into it. In our project, Smart contract is primarily required for renewable energy verification and execution of energy trade transactions. We are going to see its detailed explanation in the working section.

B3. Virtual Layer Working
The users interact with the energy transactions using a UI which functions exactly like a stockbroker app. Apart from the mechanism of bid and ask, everything remains the same.
There are a set of prosumers (Producer and Consumer) and consumers in a community. The mechanism is based on the protocols and rules defined in paper [36]. Each trading session lasts for 15 mins. At the starting of the trading session, the prosumers are asked to fill the amount of energy they are willing to trade and create an ask. At backend, this ask request creates a smart contract signed by the prosumer that offers to trade the specified amount of energy at a price calculated by an algorithm we are just going to see in a minute. When all the prosumers fill the amount of energy, they are willing to trade, then all the consumers are asked to fill the amount of energy they want and the price they are offering to pay. Then the average per unit price is calculated using the following Equation 1.

Equation 1
If this price exceeds the retail price, the rate at which energy is offered by the main grid, then the offering price becomes equal to retail price. If K remains less than the marker value, the rate at which electricity is sold back to the main grid, then the offering price becomes equal to marker price. Anything apart from this let the offering price remain equal to K. The prosumer who issues the ask first is given the priority and consumer who issues the bid first is given the priority. So, when prosumer issues their bid, they run into the contract with prosumer offering the amount of energy they want. At backend, they sign the contract published by prosumer at the time of ask with their private key. This smart contract is then floated to all the nodes present in the network. They check if the amount of electricity being supplied by the prosumer is actually present and the energy demanded by the consumer is according to the requirement. If any of the two violates the condition, then the violator is penalised with the fees. If the conditions are met, then the contract is validated, and the transaction of assets takes place. It is very important to define the assets here. Blockchains like Bitcoin, Ethereum are not flexible enough for such asset malleability. That is why for this project, we can use hyper ledger fabric, an open source blockchain library initially developed by big companies like IBM, Hitachi, JP Morgan and etc. Hyper Ledger gives enough flexibility to define the assets and associate them with a real time value. In this case, energy is the asset which is given a unique value in every trading round according to the method described above.

C. Overall Working
When a smart contract validates, it automatically releases the energy from the producer's end in the microgrid. Now, this energy does not need to selectively reach the consumer who has signed the contract. The electricity would be supplied to the consumer directly from the microgrid. Even if the demand is lower than what consumers signed up for, in the smart contract, the electricity would be supplied enough to meet the demand of the house. As we know, smart contract transactions are irreversible; the money or assets cannot be returned back. To relieve the agents from the hectic of trading in recurring 15 min slots Energy Management System (EMS) can be put in place. EMS can run into the contract without any manual interference from agents based on parameters set prior to trading. These parameters can either be set by the agent or predefined. The former is obviously preferred as it allows the agents to choose the source of energy (Renewable or Nonrenewable), budget-based bid and ask (Minimum selling price and Maximum buying price), automatic deduction or increase rate for bid and ask update at discrete intervals, etc. The question that is still unanswered is how does the blockchain ensure that the energy supplied to the home, preferring renewable energy, reaches it. Surprisingly, it does not. What blockchain ensures is that the equivalent renewable energy demanded by the consumer is released by the prosumer and that it is actually renewable energy. The former has already been answered above. As for the latter, until now the system and procedure has been quite ancient. At the energy source, a layman calculates the amount of energy produced by the system, which is then jot down in the spreadsheet. This digital copy of energy is then sent to the Renewable Energy Accounting (REA) Body which accredits the copy with a Renewable Energy Certification. This certification is then sold in the energy exchange. If we try to replicate this in a decentralised system, it will take a stupendous amount of time to even certify, let alone the distribution. This abhorrent time can be significantly curtailed from days to milliseconds using smart contract. Every device at the source is allotted a private key (Hash Value) by the REA. When a pre-specified amount of energy is collected, a smart contract is created, mentioning the amount of energy that would be given upon contract purchase, signed by the private key of the device. To crosscheck, one can use a public key to ensure that the energy is produced by a renewable source. This energy can then be bought and sold in the same manner as we saw above for microgrid energy distribution.

VII. SIMULATION
In this section, we are going to look at different scenarios of a community with respect to installation of PV, Storage and other devices and look at its results from multifaceted dimension ranging from cost to usage. All the simulations have been performed on d3a user interface powered by Grid Singularity. Simulation is set to run for 1 Day results. In all our simulation we rate per unit electricity obtained from market maker equal to 30 cents. The basic structure of the grid is as given in the following figure 4. The figures are quite self-explanatory, so the description has been kept minimum.         D. Result Looking at figures 5, 8, and 11 one can see an increasing trend in self-sufficiency as we progressively install PV and Storage. In the last case, almost 50% of the electricity is being produced within the community. The self-sufficiency factor has a direct impact on the cost incurred by an average household to buy the electricity. In the first case, cost of all the households sum up to 14.61€ as shown in figure 6 while after installing PV and subsequently storage in each household, there's a significant drop in community electricity bill. In case 2, community incurred a bill of 8.76€ (Fig 9) while in case 3, community incurred a bill of 6.96€ (Fig 12). Observing Energy pricing inside community, Case 1 has a constant price as there's no internal energy production. In case 2, the prices slump in the daylight timing due to active production of electricity from PV, while the price settles back to microgrid price during the night due to zero energy production from PV. In case 3, the overall trend is similar to case 2 but one can find lot of gaps. This is primarily because of surplus energy stored by storage. Household stores the energy in storage before trading it in the open market. So, we can make a claim that number of times houses do not take electricity from any external source but rather fulfill their needs using storage installed in their houses.

VIII. ACKNOWLEDGMENT
We would like to present our utmost gratitude to Sarah Hambridge (Product Owner at Grid Singularity), who helped us to run and understand the simulation, Garrett Macdonald, who supported us to get relevant resources through his network, and last but not the least, Prof. Divya Lohani without whose support we wouldn't have been able to complete our project.