Proof of Work Consensus Based Peer to Peer Energy Trading in the Indian Residential Community

: Rooftop solar power generation is becoming more widespread in residential microgrids. As well as new concepts of electricity markets, such as peer-to-peer (P2P) markets, where consumers and prosumers can directly exchange locally generated energy with each other without any intermediary third party for sustainable development. Data security is a big concern with energy trading; therefore, blockchain technology is being used more and more in energy markets. It has the potential to simplify P2P energy trading. In this paper, blockchain is designed to ﬁt into the decentralized nature of the P2P market, securing the payment mechanism and transaction data store. The blockchain-enabled platform is developed using the Proof-of-Work (PoW) consensus algorithm, and is veriﬁed with the help of the Postman application programming interface (API). All transactions involving the buying and selling of energy are handled by a miner without the help of any third parties. The study of a ﬁve-user residential community, whether the strategy is recommended or not, is validated through simulation ﬁndings. An overview of the results revealed that all users beneﬁted from the developed, secure P2P platform.


Introduction 1.Motivation and Bibliographic Review
The environment is constantly changing, and this change brings with it innovation and efficiency.Change, innovation and progress have resulted in damage to the ecology and climate around us.The ozone layer has been damaged as a result of increasing CO 2 emissions.In addition, other hazardous gases, especially those from fossil fuels, have had a significant impact on climate.Due to the rapid change of climate, high-level reforms should be made to keep the earth.Because of this, in recent decades, the world has shifted from the traditional use of fossil fuels to the use of renewable green eco-friendly resources [1][2][3][4][5].These days, renewable energy sources are the talk of the world, and their economy is visible [6,7].
The importance of producing clean, renewable energy is essential to ensure a sustainable environment for future generations [8].P2P energy trading systems are a small step in this direction, which could help the achievement of the sustainable development goals.Energy trading platforms that trade energy among peers focus on efficiency and sustainability.Peers generate all their green energy and distribute it through a peer-to-peer trading system.P2P trading platforms can distribute energy efficiently between the peers.Peers are free to choose any local energy source of their choice, solar panels or wind turbines.As a result of this assumption, the energy system has its grid infrastructure and technologies in a way that includes web-based apps to ensure that users of the grid can access it easily [9].They leverage block chain technologies to create an open and state-of-the-art internet-based decentralized platform for the exchange of energy data where buyers, sellers, energy producers and energy dealers can easily communicate and work together.In this way, P2P platforms supports sustainable development goals [10].
In the existing energy market system, distributed generation resources and consumerowned generators (i.e., prosumers) are increasing continuously [11].The surplus renewable energy produced by producers is supplied directly to the grid.In return, producers obtain some economic incentive depending on the amount of surplus PV electricity supplied to the grid.In addition, it depends on the tariff plan of the different countries and distribution network operators (DNO) [12].However, the incentives are very small compared to the cost incurred during PV power generation.Consumers do not obtain any incentive to take electricity from the grid; instead, they pay a very high price for the supply of electricity [13].Therefore, neither the producers nor the consumers are obtaining any benefit in this energy market system.This issue may be overcome by the coming P2P market [13].In this market, energy is exchanged directly between the two prosumers using the existing electrical grid network without going through a third party (i.e., distributed network operator (DNO)) [14].In energy trading, peers only use the local network.In energy trading, peers only use the local network, and instead pay network fees or service charges directly to the DNO.In addition, there is no involvement of DNO in decision-making and other planning.Thus, other charges are not applicable on the energy trading platform.Consequently, when there is no third party, there will be no charges other than network charges.This would lead to more incentives for producers and lower costs for consumers.
To achieve energy-related goals, users of a P2P network can share their resources (such as storage space and renewable energy) with their peers.Maximizing the use of renewable energy sources, reducing network maintenance and capital expenditure, reducing peak loads, and minimizing electricity costs are some examples of such goals.Each peer can interact directly with other users of the network without going through a middleman controller, and each user can be either a supplier or a buyer of network resources or both.In addition, a new peer may be added to the network or an old peer may be removed without changing the way the system operates.
Numerous research studies are being conducted to investigate the opportunity of P2P energy trading among various prosumers because of the possible advantages.A prosumer with an energy demand can be taking benefit from other prosumers in their community who have an energy surplus by purchasing the extra energy at a significantly lower price on a P2P trading platform [15].In Ref. [16], in contrast, prosumers can buy or sell energy from each other under the Feed-in-Tariff scheme that will encourage buyers to buy energy to reduce their electricity costs while maximizing profits for the seller.In Ref. [17], peer-topeer (P2P) trading platforms use a continuous double auction architecture as the market mechanism.Ref. [18] recommends an auction method based on a hybrid double auction framework that makes it easier for micro-grids to trade energy.It employs a hybrid optimization technique combining model genetic algorithms (GA) and particle swarm optimization (PSO), in order to clean up the auction market.In Ref. [19], the P2P energy trading market based on double auction architecture has been introduced which operates on an hourly forward basis.In Ref. [20], a P2P energy trading network designed based on a non-cooperative and cooperative game theory.A multiagent based P2P energy trading platform is discussed in [21].
Furthermore, various ongoing existing P2P platforms for local energy trading have been presented in Table 1.Yeloha and Mosaic, Vandebron, Piclo, and SonnenCommunity are the regional and national level trading platforms that support the trading between peers, and the owner of the platform acts as a supplier in the energy market.These platforms did not consider Information Communication Technology (ICT).The unit electricity price is changed from time to time in the Vandebron and Piclo platforms for consumers and generators.The importance of energy storage technology is incorporated with the SonnenCommunity platform.Smart Watts and PeerEnergyCloud are ICT based platforms that are more reliable for local P2P energy trading and have proposed various business scenarios for energy trading.The advancement of ICT technology is the primary innovation with these platforms.Finally, Brooklyn Microgrid, Lumenaza, TransActive Grid, SOLshare, Centrica plc and Electron platforms addressed the blockchain technology into energy trading fields to simplify the process of metering and billing in the energy markets.However, the TransActive Grid platform is more interested in introducing a local energy trading market in residential communities.

Smart Watts Germany
Utilize information and communication technology to maximize energy efficiency.This platform uses a smart meter gateway as an interface to the Internet of Energy for an effective operation devoid of any kind of control system. [23] Peer Energy Cloud Germany Designed an energy trading platform using cloud-based technology that takes into account the predicted profiles of nearby appliances.[24] Piclo UK Designed for the direct energy trading.The challenge is that that is no discussion about the local energy market. [25]

Vandebron Netherland
Designed for the prosumers who trade directly.The cost determined by prosumers using this platform.It links the generator, prosumers, and consumer to maintain equilibrium in the wholesale energy market. [26]

Yeloha and Mosaic US
Designed for the non-solar commercial community, they do not own a PV system.They are paying for PV power generated as a result of lower electricity consumption costs.
[27] SonnenCommunity Germany Designed a trading platform with battery energy storage.[28] Community First!Village Texas Designed community-based energy trading platform.[29] TransActive Grid UK Designed a trading platform including blockchain technology.[30] Electron UK Designed a blockchain and ICT based energy trading platform. [31] Brooklyn Microgri USA Designed blockchain-enabled trading platform for energy trading within communities. [32] Centrica plc UK Designed a blockchain-enabled local energy trading platform by using storage, RE generation, and flexible demand.[33] Lumenaza Germany Designed a local energy trading platform for regional and national level [34] SOLshare Bangladesh Designed small-scale energy trading market to connect local consumers who installed PV systems at their homes.[35] A significant research gap has not been explored in the literature: how to develop a reliable trading platform without a central controller for energy trading amongst many peers in a community that will guarantee their broad and long-term participation in the electricity market.Therefore, it may not be easy to get prosumers to collaborate and put their trust in one another while exchanging energy.The biggest obstacle to P2P market design is the lack of trust and transparency in trading between peers within the community [36].The P2P trading network needs to be supplemented by a secure and reliable distributed system that keeps track of all transactions in a way that is immutable, visible, and tamper-proof.Secure transaction approaches are required in local energy trading to secure the openness and reliability of each transaction process for each user [37].
To overcome these difficulties, P2P energy networks typically consist of a virtual trading layer and a physical transfer layer [32,[38][39][40].The virtual trading layer fundamentally imitates a local electricity market, where participating peers of the network communicate crucial data to determine the resource type, resource amount, and price per unit of resource exchanged with another.A virtual layer must be designed upon secured data (i.e., blockchain based layer [41]) that can enable transparent and decentralized transactions.Automation, security, and transparency are all made possible by blockchain technology.The microgrid level blockchain enables trading platform is designed in [42], and the result presents that the system will no longer rely on a centralized system to trade energy.
The money transaction and energy exchange information is collected in the physical layer after the completion of buying and selling bids matching between peers.Furthermore, the physical layer is utilized for actual energy transactions between peers.This layer may either be a system operator or a distribution network operator.It is important to note that the peers of the virtual layer do not immediately influence financial transactions based on how the power is physically distributed.In actuality, the buyer pays the seller to begin the process of transferring the seller's renewable energy into the distribution system.

Aim and Contribution
In this work, a secure blockchain platform designed based on Proof-of-Work (PoW) for the P2P energy trading in the local community.Blockchain reduces the centralized control of organizations responsible for authenticating transactions.This requires a properly functional consensus process to maintain the trustless, immutable, and distributed properties of the network [43].The two primary consensus technologies currently employed in blockchain-based secure energy trading are PoW and proof-of-stake (PoS), which independently validate transactions.In PoW, miners must spend a lot of money on electricity in order to process a block on the network and solve challenging mathematical puzzles.The machines that produce digital assets through the mining process, which is the process of verifying transactions, are powered by energy.The use of energy is also essential to the security of the network as it enables it to maintain accurate transaction records and adhere to predetermined, reliable monetary policy.Proof-of-work consensus has been incorporated into the bitcoin system, and it is able to mine additional blocks [44].Furthermore, it maintains the security of the network as it would require a malicious actor to have 51% of the network's computing power to attack the chain [45].Miners will have to choose whether to switch to the new split blockchain network or support the original blockchain if the blockchain is forked under the PoW system.To keep up with both, a miner would have to split his processing power between the two fork sides.Proof-of-work systems inherently prevent further forking and incentivize miners to choose the side that does not want to destroy the network by providing financial incentives [45,46].
Despite the advantages mentioned above, PoW can be extremely costly and resource inefficient.Miners may have to deal with a variety of costs, including digital infrastructure equipment that depreciates rapidly [36].Furthermore, when the network is congested, the transaction costs of the system are high.Having more blocks and miners requires a larger amount of computational mining power.The cost of mining will be expensive as a result of the high energy consumption [47].To address this issue, proof-of-stake (PoS) [48] has been introduced, modifying the mining probability such that it now depends on participant stake.PoS-based systems are also far more scalable than PoW-based systems and authorize transactions more quickly [49].By adjusting the system's parameters or modifying its consensus process, the system can scale to handle more transactions per second than typical existing systems [50].By reaching a consensus before blocks are created, PoS networks are able to handle thousands of requests per second with latency of less than a millisecond.Decentralized trading systems are implemented in this way, and the computational load is reduced.
On the other hand, Proof-of-Stake has its own unique set of difficulties.For example, the largest token holders still have the ability to control the network.Early adopters and wealthy individuals benefit the most.In contrast to proof-of-work [46], this paradigm lacks a performance history.In addition, forking is not always discouraged in PoS systems.When the blockchain splits, the validators will receive a duplicate copy of their stake on the newly forked blockchain.When a validator authorizes both sides of the fork, they may be able to double spend their coins and double in transaction fees [51].
The above justifications make it clear that both the consensus processes have advantages and disadvantages.Although they all work towards the same basic goal, they employ different strategies to get there.The key difference between the two consensus systems is that transaction verification is delegated and rewarded [52].
The requirements of a network determine the type of agreement that is necessary i.e., fraud prevention, network security and trust-building all require PoW [53].Due to the security provided by PoW, miners cannot be misled about transactions.Proof-of-work is a technique for protecting the transaction history of a crypto asset, as well as making it more difficult to change data over time [46].Participating nodes must prove that the task is finished and submitted in order to be approved for adding new transactions to the blockchain, protecting against any malicious behavior [54].PoW helps in locating the most trusted copy of the blockchain when there are multiple versions on the network.The development of a distributed clock that allows miners to freely enter and leave the network while maintaining a constant operation rate is also dependent on proof of work.Similarly, using POS-based technology has a significant impact on network performance and security.PoS is used when on-chain transactions per second and actual network transfer settlement calls for higher transaction speeds [43].Furthermore, validators are likely to own a sizable amount of network tokens, which provides them with a financial incentive to maintain the security of the chain [44].
The small scale network has been considered in this study.Therefore, the authors have not considered transactions per second and higher transaction speed for actual network transfer settlement have not been considered in this work.Additionally, the focus of the paper is on security, fraud prevention, and trust-building in networks.Therefore, to achieve this, the paper employs a proof-of-work consensus mechanism, allowing the network to agree on which transactions are valid.Each node in the microgrid is divided into two groups: prosumer that are able to generate their own renewable energy and consumers who need electricity to meet their demand.Additionally, this study assumes that each node is a smart house with IoT devices connected to the Internet and energy storage that can store the energy generated from PV systems.The energy storage architecture is considered in a decentralized manner.The home miner can manage Energy Storage System (ESS) devices as well as track the energy consumption profiles.Prosumer miners have excess energy, so they can participate in energy trading using a private blockchain according to a pre-determined smart contract script.This study focuses on developing countries' (India, Pakistan, Bangladesh, Brazil, Kenya, Colombia and the Philippines, etc.) scenarios, which have sufficient renewable generation and digital infrastructure.The main research objective of this study is as follows: 1.
A blockchain platform developed using a PoW consensus algorithm application with a proper mining mechanism for energy training services; 2.
Developed trading platform validated with a case study and analyzed energy trading digits; 3.
One-day electricity cost has been calculated for each user with decentralized energy storage architecture and also compared the benefits of the platform over traditional prosumers/consumers to local grid trading.

Paper Framework
The rest of the study organized as follows: Section 2 describes the various taxonomy of the simulation work with PoW consensus algorithm.In Section 3, develop a blockchain platform for energy trading between prosumer and consumer.Section 4 presents a case study for a validated developed blockchain platform.Section 5 show the implementation of blockchain for the energy trading process.Section 6 presents the results of this research study.Finally, Section 7 brings the essay to a close.

Layers
Two layers comprise a P2P distributed energy network.The first layer is composed of physical energy networks, while the second layer is composed of virtual energy trading networks [55].

•
Physical Layers: The physical layer is utilized for actual energy transactions between peers.This layer may either be a system operator or a distribution network operator.
It is important to note that the peers of the virtual layer do not immediately influence financial transactions based on how the power is physically distributed • Virtual Layers: The blockchain-based architecture of the local energy market is provided by the virtual layer energy trading platform, through which all types of data are transferred.For instance, peers' data on electricity generation, consumption, and demand are transmitted to the virtual layer via smart meters over a communication network.All buy and sell requests are submitted on the virtual layer, where they are matched and accepted, payments are made between peers, and energy is traded on the physical layer.Financial exchanges take place on a virtual layer and have no impact on how energy is physically transferred.

Peers
Peers are those who trade additional renewable energy generated in the neighborhood or inside the network.

Node
Data blocks are linked together to form a blockchain.These data blocks are placed on the nodes of the network.Nodes can be any size or shape (mostly computers, laptops, or even larger servers).Nodes are the foundation of the architecture of a blockchain.Each node on the blockchain is interconnected and regularly exchanges the latest blockchain data, ensuring that each node is always up-to-date.Nodes store, distribute and protect blockchain data.A full node is essentially a piece of equipment (like a computer) that keeps an up-to-date copy of the transaction history of the blockchain.

Miner
Blockchain mining is the process of adding transaction records to the blockchain to secure and verify them.This process of adding blocks to the blockchain enables the processing of transactions and the secure movement of money.This process of blockchain mining is carried out by a global network of individuals called "blockchain miners".Transactions are first digitally signed and issued by the user, and then transmitted over the blockchain network for verification.This process is known as mining.Miners verify the validity of users and transactions.Verification is a competitive process, as the miner who validates the new block first broadcasts it.The last nodes in the chain validate the broadcast block by stopping mining on that block.

Consensus Algorithm: Proof of Work (PoW)
According to Bitcoin [56,57], the PoW mechanism searches for a value whose calculation begins with a specific number of zero bits in the hash.To achieve this, a nonce is multiplied by the initial value until the resulting hash starts with the required number of zero bits.After nonce is found and proof of work is received, the block cannot be updated without having worked for that specific block and all subsequent blocks.
Each block has a hash, except for the first block generated by the system (genesis block), which is made up of the hash of the previous block and is not necessary to create the appropriate zero bits, as shown in Figure 1.The hash of the originating block is composed entirely of zeros because it does not contain any preceding blocks.The proof-of-work protocol is used by Bitcoin 2 to ensure that each participating node is on the same branch of the blockchain [58].The protocol requires nodes to complete a challenging computing task before a new block is proposed.The node finding the solution initially mines the new block and transmits the information to other nodes in the network so that they can use the data in the block to quickly verify its accuracy.This is because all previous hash values inside the blockchain must be known in order to have valid hash values in future blocks.A single block in history can be modified by an attacker, altering the block hash and rendering the entire successful blockchain invalid.When multiple users verify a block simultaneously, which is highly unusual, the network splits until new blocks have been mined, after which all nodes converge to the most recent longest list of blocks.
A detailed description of the PoW algorithm is presented [56,59].The bitcoin network employs PoW as a consensus method [60].In a decentralized network, one has to choose to track the transactions.Random selection is the simplest method; however, it is vulnerable to attack.Thus, if a node wants to publish a block of transactions, it will take a lot of work to prove that the node's network is unlikely to be attacked.In most cases, the work involves computer computation.
As presented in Figure 1, the blockchain architecture is made up of a series of blocks.This indicates that each block, except the genesis block, has a relationship with the previous block header hash value ("preBlockHeaderHash: h()").Additionally, each blockchain block consists of two components: a block header and a collection of transaction data.Each node in the PoW network determines a block header hash value.
The block header contains pre, nonce, transaction counter, and Merkle tree parameters.Pre stands for previous block header hash function, nonce for PoW solution of the block.R i stands for the root of the Merkle tree, which is produced by the transaction counter.
A block header hash value is determined by each node in the PoW network.According to Figure 1, block headers contain a nonce and minors, which are regularly changed to generate different hash values.The estimated value, by contract, must be less than or equal to the specified value.When a node receives the required value, it broadcasts the block to all other nodes, which must then independently verify that the hash value is correct.If the block is genuine, then other miners will add this new block to their own separate blockchain.The PoW mechanism in Bitcoin is referred to as mining, and the nodes that determine the hash value are called miners.A valid block can be produced concurrently in a decentralized network.When multiple nodes search for the relevant nonce, it is unlikely that two conflicting forks will simultaneously produce the following block.In PoW protocols, a chain that gets longer is considered real.The mining process continues until a long branch is found.The amount of computer power used by miners uses up a lot of resources.In an effort to mitigate the risks, some PoW technologies have been created that allow some possible side-applications.

Smart Contracts
A smart contract is a piece of computer software that allows two peers to make realworld contracts.A computer language such as solidity is used to build a smart contract.It comprises an application of logic and an execution condition.When a peer begins a transaction that meets the circumstances, these execution requirements are immediately invoked [61].The blockchain only keeps the data associated with a smart contract after it is activated.The smart contract [62] is kept in an immutable state by each peer.Smart contracts are used by the majority of blockchains with permission.In contrast to a permissionless blockchain like Bitcoin, where anybody may participate, the members of a permission blockchain are known in advance.It enables the setting of rules governing the blockchain's operation.

Data
Data are the most basic need for a block to be recorded on the blockchain.It can be in any format, such as text, audio, video, and potentially other smaller blockchains may all be included.The data we are using are unique to this study.The following attributes are included in the data set:

1.
Sender: This area will include the contact details for the information supplier.The user's unique profile ID will help in supplier to tracking and preservation; 2.
Receiver: This section will include the contact information for the buyer.The user's unique profile ID will help in tracking and keeping track of collecting information, as well as calculating the amount of energy used on a daily basis using data analysis;

3.
Transaction: The amount of information exchanged between sender and receiver, known as transaction; 4.
Amount Paid: The amount paid in exchange for information.Payments can be made in our blockchain's native coin, but we also want to include actual money.Real money will have its fundamental worth and will not fluctuate like cryptocurrencies; 5.
Timestamp: Timestamping is a key component of blockchain technology that is integrated automatically and categorizes all transactions chronologically; 6.
Nonce: A nonce is just a random number generated until the required value is discovered; it is utilized in the Proof of Work process mentioned in the next paragraph.

Software Platforms For Development
The exact software tools needed to implement the proposed concept are a significant problem.During the research stage, many tools have been investigated and evaluated, which is followed by numerous upgrades.Finally, the following software applications have been chosen.

Postman Tool
Postman is a scalable API testing software tool that integrates rapidly into CI/CD pipelines.APIs enable interoperability between software programs by facilitating API calls.

•
GET Request: Information can be retrieved from a given URL using get requests.The endpoint will not be altered in any way; • POST Request: Post requests differ from Get requests in that the user adds data to the endpoint, which involves data modification.

Windows Visual Code
On your desktop, Visual Studio Code (VSC) is a small-but-powerful source code editor for Linux, macOS, and Windows.In addition to a huge community of extensions for additional languages and runtimes (including Java, C++, C#, PHP, and Python, etc.), it has built-in support for Node.js,TypeScript, and JavaScript.

Git Bash
Git Bash is a program that imitates the Git command line on the Operating System.It is a command-line shell for enabling git via the system's command line.A shell is a type of terminal program that allows users to communicate with an operating system via typed commands.Git Bash is a package that installs Bash, several commonly used bash programs, and Git on Windows.The user interacts with the repository and git elements via commands in Git Bash.

Node.Js
Node.js is a framework for quickly building scalable and agile network applications and is based on the JavaScript engine in Chrome.Node.js is fast and efficient because of its event-driven and non-blocking I/O architecture.As a result, it is ideal for real-time, data-intensive applications.

Development of the Blockchain Platform
This framework enables a network to be created with any arbitrary number of nodes.When it is first started, each node has a set of neighbors, although after startup, nodes in this list can be added or removed.Each node selects its local blockchain state, active transaction log, and a group of neighbors.Each node also acts as a miner for the network.In order to mine new blocks and develop their blockchain first, miners always work to solve proof-of-work.A miner notifies his neighbors when he has successfully mined a new block.The information is shared asynchronously, and the miner immediately starts working on the next block.Different nodes may receive information in different orders because the information is distributed asynchronously.Assuming that the two nodes are executing as separate processes on the same system and are using ports as stand-ins for their physical locations, the network delay between them is measured by the difference in their port numbers.Each node exposes multiple HTTP endpoints that can be used to exchange this information to contribute new data, such as transactions or new blockchains.Additionally, these queries are completed asynchronously to avoid interference with mining operations.Nodes validate a new blockchain upon receipt, and if the new blockchain is longer than their current version, they update their copy.Some transactions may go uncommitted during the merge process; as a result, nodes merging the blockchain keep track of any such transactions and add them back to the list of pending transactions.To provide their state information, nodes also provide other HTTP endpoints.These are used to implement network-built visualization tools.The development stages of the blockchain platform are as follows: 1.
Node Connection/ Making Peers: First, connect the virtual node to our window by sending a POST request to the Postman API Tool, as shown in Figure A1 in Appendix A. Nodes can be of any type, primarily computers, laptops, or even larger servers.Initially, three virtual nodes are created at a Windows server computer's IP address ("http://127.0.0.1:").Each node has a unique ID, 50001 to 5003, as shown in Figure A2 in Appendix A. All nodes on a blockchain are connected and regularly exchange updated blockchain data.

2.
Block and Blockchain: The block is the fundamental unit of a blockchain.A blockchain data structure is built by linking these blocks in a sequential sequence.Hash, data, and previous hash are the characteristics that make up the block as shown in Figures A3 and A4 in Appendix A.

3.
Mine Block: The basic structure of the blockchain is shown in Figure A5 in Appendix A, i.e., it has a transaction or genesis block which is predefined in any blockchain network because, initially, its index value is 1.The adding process of transaction index value is shown in Figure A6 in Appendix A. The transaction index increases after mining, which means that the transaction is added to the block.
To add a transaction to a block, one must first mine that transaction as a fundamental principle of blockchain technology, as shown in Figure A6 in Appendix A. In the mining process, it solves some mathematical equations to add up the transactions in the stipulated time.The miner obtains a reward after each successful mining of a transaction that is being added to the block.By using GET request, we mine the block in the blockchain using postman API.

4.
Adding a Transaction: In the Postman API, a transaction is created using JSON format as shown in Figure A7 in Appendix A by using a POST request.However, if we request to obtain a chain in Postman API, it will not add that transaction to the blockchain as shown in Figure A8 in Appendix A. Because a fundamental blockchain principle states that any transaction will be added to the block after the mining process, and because we did not mine our block, the transaction was not added to the block.After the mined, the block transaction is added in the blockchain as shown in Figure A9 in Appendix A.

5.
Actual chain: After adding a transaction to the blockchain, we obtain the actual chain using a GET request in the Postman API.As a result, in Figure A10 in Appendix A, a complete transaction added from the mining reward to the genesis block is presented in that blockchain.It shows this by using this timestamped transaction with a different nonce value.We can create an energy trading platform using these back-end programs.It shows the basic development of blockchain architecture using these software tools.These types of transactions occur in energy trading between nodes, and that's how we secure the trading data using blockchain technology.

Case Study
In this study, a local energy network is made so that people in the same area can share energy.All the houses are interconnected, and they can communicate and share energy among themselves.The per-day electricity cost of a community house is calculated in two scenarios.Scenario: 1 shows that all the homes in the community are connected to the grid and that the grid can meet all the homes' needs at grid prices.Scenario: 2 houses have PVs installed, and they trade their extra PV power with their neighbors safely.
Scenario: 1 The electricity purchase cost from the grid to meet the jth consumer's demand presented in Equation ( 1): Scenario: 2 Prosumer investment and operation cost determined in this scenario.The main goal of Prosumers is to minimize the total investment and operating cost.The overall total cost TC j of jth prosumer is represented in Equation ( 2): The I j and O j are the present investment cost and operating cost of the jth prosumer, respectively.Power capacity and energy storage capacity combined make up the daily investment cost of the jth prosumer's energy storage system, as presented in Equation (3): The power capacity and energy capacity of the energy storage device are taken into separate consideration while calculating the investment cost.The cost of energy capacity mostly comprises the cost of energy storage devices, while the cost of power capacity primarily involves the cost of an energy conversion converter.The jth prosumer benefits from energy shifting because its reduced overall operating cost is equal to the sum of the cost of energy received from the grid when PV generation is insufficient to meet jth prosumer demand and the revenue from energy sold back into the grid or traded with peers: Et j,t = Et j,(t−∆t) + ∆t η C P C j,t + P pv j,t The energy storage charging and discharging limit are presented in Equations ( 5) and ( 6), respectively.The minimum and maximum energy limit of the energy storage during the operation is presented in Equation (7).The present state of energy storage has been tracked between successive time interval using Equation (8) considering charging and discharging efficiency.

Case Study Data
The data for this study are taken from five consumer residential societies of IIT Bombay [63].In the five houses, three are the consumers represented by C − 1, C − 2, and C − 3 and two are the prosumers which are represented by P − 1 and P − 2. The prosumer have installed 5 kW and 2 kW rooftop solar power systems.Prosumers have installed battery energy storage at their premises.Energy storage helps to prosumers for maximum uses of generated PV power.Additionally, it reduces the need to rely on the grid during periods of high demand.The technical specification of energy storage has been presented in Table 2.The deep learning model i.e., LSTM has been used in the day ahead forecasting.The LSTM model is more capable of capturing nonlinearity of data pattern and gives the better accuracy as presented in Refs.[64,65].The performance metrics of the forecasting results are presented in Tables 3 and 4 without assessment of input data uncertainties.The forecasted PV power generation profile has been shown in Figure 2 for a specific day (11 May 2017).The forecasted demand profile of individual consumers has been shown in Figure 3, and observed that consumer C 3 has large demand; therefore, it will participate in a local energy sharing market to reduced their energy bill.The day ahead forecasted electricity grid price profile has shown in Figure 4, which is taken from an IEX web portal [66].The prosumers P 1 and P 2 have excess energy after fulfilling their own demand compared to both prosumers that will participate in the energy sharing process.

Simulation Assumptions
The simulations assumptions of this study for the users include how they are shared energy in the community and how blockchain technology can be used with energy-sharing digits.The energy trade will be conducted on the basis of their excess PV power generation and demand.There are certain assumptions made for this approach as follows: 1.
The energy trading price assumed 2.10/KW for the selected day, which is the 10% less to one day average electricity price.It will be updated for each day, but the fixed for the whole day; 2.
The prosumer will first meet his own demand; then, if the PV power generation is excess to the demand, then the trade will be executed; 3.
The prosumers must have a minimum of 0.5 kW of excess PV power to participate in the trading process; 4.
The installed storage capacity at Prosumer miners' homes is equal to the required energy to meet the demand.Therefore, after the charged energy storage, and they sell excess PV power to consumers in PV hours; 5.
In this study, the 9:00 a.m. to the 5:00 p.m. time interval has been assumed for the trading.6.
We have 5 kW and 2 kW PV power generation units on two prosumers.7.
If a prosumer has no excess PV power equal to the demand of all consumers, he will first trade the one that has higher demand.

Implementation of BlockChain for Trading
Based on the platform built in Section 3, the blockchain-enabled platform is used to trade energy with a neighborhood of five homes.First, five virtual nodes are created at the Windows Server computer IP address ("http://127.0.0.1:").The nodes are displayed from a separate screen, as shown in Figure 5.Each node has a unique ID as shown in

Energy Trading Process
The prosumer miner continuously tracks its own consumption and available energy in its energy storage.If the prosumer miner finds that the energy available in the storage is insufficient, and is less than the specified required amount.According to the specified terms and conditions of the smart contract, the trading process will start between P-1 and P-2 miners.When the energy storage is fully charged and excess PV power continues coming from solar, then prosumer miners can trade excess PV power generation to consumer miners at a defined trading price to generate revenue.Consumer miners are also interested in buying energy from prosumer miners at less than grid prices.In this way, miners participate in the trading process to reduce their electricity costs or generate revenue.The implementation guidelines for miners are as follows: 1.
P-1 and P-2 miners must register in the smart contract, which contains the terms and conditions of the transaction, in order to sell energy.The smart contract is added to the block once the PoW has been validated; 2.
Consumer and prosumer miners both contribute to the finalization of transaction prices and the script of laws and regulations.The price and transaction processing are added to the block after the PoW is validated; 3.
The matching transaction starts once the consumer's miner alerts the consumer miner of his wish to make a purchase if he notices a demand for energy; 4.
The energy transaction is finished if the transaction matching is successful.As a consequence, consumer miners obtain energy, and prosecutor miners profit from this.

Results and Analysis
In this section, energy trading digits between miners are presented with blockchain data.In addition, prosumers' and consumer miners' one-day electricity costs have been calculated in two scenarios.The blockchain enables P2P energy trading and has been considered in Scenario: 2. The detailed analysis of the results is as follows:

Energy Trading Digits
Transactions between nodes in relation to time are shown in Table 5, with consumer miners being the first to trade with consumer miners with maximum demand.Table 5 presents the amount of energy traded between miners and their total cost based on a predetermined selling price.The total energy traded from individual consumer miners to individual consumer miners is presented in Table 6.The PV power output of P − 1 miners exceeds their required energy demand.Therefore, trading points are higher with individual consumer miners than with P − 2 miners.Figure 6 shows aggregate demand, PV power demand, peer demand, and grid power numbers for individual miners.Maximum energy trading by P − 1 miners, as P − 1 miners have more PV power capacity than they demand.

Blockchain with Trading Data
As discussed earlier in Section 3, the trading points of all transactions between connected nodes will be stored on the blockchain for the privacy and security of the users.Through that process, transactions are added to the blockchain, so that these transactions are tamper-free and the assets of the blockchain cannot be changed.Transaction points are stored in the blockchain as a sender (consumer) amount and a receiver (consumer) amount.Digits are stored on the blockchain with value, as shown in Figure A11.The actual timestamp also stores the index value, previous hash function value, and sender and receiver sum digits.

Economic Analysis
The electricity cost for a day has been calculated based on the respective prosumers and consumers of PV power generation and demand, as presented in Table 7.In Scenario: 1, the total cost of the users is calculated based on the demand of the respective users.In Scenario: 2, the total one-day electricity cost has four components.The investment cost only applies to prosumers because they have installed the PV and battery at their residence.The cost of energy to buy off the grid applies to each user.However, P-1 and P-2 store the additional PV power in a storage system and use it when needed, so their grid cost is zero.The operating cost or revenue of storage also applies to P-1 and P-2.This component is negative, meaning they received revenue from additional energy sold to C-1, C-2, and C-3.The net electricity cost for P-1 and P-2 is negative, excluding investment costs, meaning that P-1 and P-2 make a profit by trading excess energy with their peers.The net electricity cost for C-1, C-2, and C-3 is derived by combining the cost of energy from the grid with the cost of energy from peers.In Table 7, the net electricity cost for the day specified in Scenario: 2 is lower than in Scenario: 1.

Conclusions
In order to reduce the dependency for trusted peers to transactions and improve the authenticity and reliability of data, this study was started to build an energy trading platform among nodes in a residential microgrid setting using PoW enabled smart contracts and blockchain technology.This study demonstrated that the trading platform offers both buyers and sellers the chance to generate positive profit through participating in the trading process.The findings of this study also indicate that the excess energy generated by each node can be exchanged effectively in the context of a microgrid with less assistance from a distribution system operator (DSO).Additionally, it has been seen that the payment module properly transfers funds to players' accounts without the involvement of a third party.Additionally, the use of blockchain technology leads to the chaining together of transaction data into blocks.Thus, it becomes impossible to tamper with.In comparison to traditional database technology, it can be said that blockchain technology increases the authenticity and trustworthiness of data.The proposed study does not support undeveloped countries or rural areas of developing countries due to a lack of development in recent advancement in technology and digital infrastructure.This study has been conducted considering developing countries (India, Pakistan, Bangladesh, Brazil, Kenya, Colombia, the Philippines, etc.) scenarios, which have sufficient renewable generation and digital infrastructure.
At the transaction level, there are still several significant obstacles for blockchain technologies utilized in the electricity sector, despite the fact that numerous kinds of blockchain for P2P energy exchange have been copied or implemented in current times.Future research will thus concentrate on how blockchain technology might be incorporated into the technical operation of electricity grids.A transaction may be compared to a direct control system where the inputs are money, and the outputs are goods.This conviction drives us to concentrate on integrating blockchain technology into distributed control of power systems in order to increase the scope of potential application scenarios.In addition, overheating of transformation stations problem may include overcoming the DNO problems.
Figure A2.Consumers (C − 1, C − 2, and C − 3) and Prosecutors (P − 1 and P − 2) are the blockchain miners of the trading process.The node IDs are 5001 and 5002, which represent the charger miners P − 1 and P − 2, respectively.Consumer miners C − 1, C − 2, and C − 3 are assigned the remaining IDs 5003, 5004, and 5005.All nodes on a blockchain are connected and regularly exchange updated blockchain data.

Figure A3 .
Figure A3.Construction of Block and PoW.

Figure A5 .
Figure A5.Obtain the current status of Blockchain.

Figure A6 .
Figure A6.Mined a Block using GET request.

Figure A8 .
Figure A8.Transaction will not be added in a block.

Figure A11 .
Figure A11.Sender and receiver amount digits in an actual chain.

Table 1 .
Summarize details of existing P2P Platforms.

Table 3 .
Prediction performance measures on individual users' load forecast error data.

Table 4 .
Prediction performance measures on PV forecast error data.

Table 5 .
Energy sharing data.

Table 6 .
Total energy trade between prosumer and consumers Figure 6.Consumer and prosumer demand meet chart.

Table 7 .
One day total electricity cost (Rs.) of prosumer and consumers.