Peer-to-peer electricity trading system: smart contracts based proof-of-benefit consensus protocol

Nowadays, people trade electricity through centralized companies or organizations which is vulnerable to cyber attacks and incapable of coping with increasing demands from stakeholders. In this paper, we propose a new Peer-to-Peer Electricity Blockchain Trading (P2PEBT) system based on the current charging and discharging schemes for electric vehicles (EV) in the smart grid to enable users to participate in the trading process. In order to cope with the current situation of the high volume of EV integration, the proof-of-Benefit (PoB) consensus primitives are proposed for P2PEBT to achieve demand response by providing incentives to balance local electricity demand in the novel blockchain system. PoB is implemented by executing the smart contracts on the Ethereum platform, and the process of achieving the maximal benefits is completed by submitting the transaction in the decentralized network. Security analysis shows that the P2PEBT system is able to manage a potential protection against up to a number of attacks. We demonstrate that the proposed system using the PoB consensus mechanism can achieve lower power fluctuation without requiring a third-party intermediary.


Introduction
The large-scale integration of renewable energy sources imposes huge challenges in the current grid systems, mostly due to the fact that the power generation and management from renewable energy sources are intermittent and fluctuating.Moreover, the fast-growing adoption of EVs brings challenges to the traditional power grid system, where the significant load demand precipitated through the integration of EVs burdens the power transmission substation and affects voltage stability in the power consumption during the peak time.
Traditional power grid system is becoming more vulnerable, so the smart grid which combines the stand-alone microgrids and large-scale electric power plants is envisaged to be the next generation power grid [1].It enables two-way flows concerning electricity and information which enables an automated operation and the capability of the distributed network operator to preserve the stability and resilience of the grid system [2].Also, EV can be treated as mobile energy storage with the bi-directional electricity flow features to provide ancillary services, such as load flattening, peak shaving, and frequency fluctuation mitigation [3].Then the vehicle-to-grid and grid-to-vehicle concepts are designed that act as the provision of promoting greener energy from the surplus energy in EV to the grid system [4].
To realize a stabilized grid network by favoring the balance of the excess electricity amount in the EV, various charging and discharging scheduling techniques are proposed.The author [5] proposed an optimal scheduling and overall load reduction problem in the islanded operation mode, and it used the distributed computation method to run the optimization problem for the microgrid operation.The proposed solution finds out the minimal amount of power load reduction while ensuring the basic requirements for reliable grid network operation.Moreover, a stochastic program that incorporates the risk management in [6] is proposed to provide frequency regulation service with the aid of EVs and an aggregator.The author [7] proposes an aggregation-based optimization model for EV charging considering the random features in the charging procedure including arrival time and state-of-charge.In [8], the proposed scheme used centralized aggregator to optimize the power loads which lacks individual decision and undermines the autonomy of the grid participants.However, the aforementioned schemes rely on electricity consumption or bill predictions, and the training data is based on historical power consumption and user profiles.In [9], a dynamic price incentives market mechanism is proposed to balance the local renewable energy production and support flexible demand.In [10], the blockchain based trading platform is proposed to support decentralized energy market with distributed optimization and control.In [11], a more sophisticated dynamic power network infrastructure is able to advance the small-scale generators and overall resilience.In [12], a transactional energy system is introduced to increase the flexibility of the energy transaction.Transactional energy is a sequence of energy transactions for a delivery of an amount of energy commodity in the specified timeframe and location to support business for all parties including power generators and distributed system operator.Henceforth, the distributed electricity trading platform is based on the frequent communication of offers and demands among the power consumers and operators respectively.
In the traditional energy trading system, it normally involves order generation, broker-dealer, trade compliance, order management, price delivery, exchange execution and settlement accounting, which are time-consuming and lack of flexibity [13].Based on the aforementioned studies, the energy trading process in the decentralized system can achieve demand response by incentivizing EV owners to trade electricity regarding their self-interest [14].Applying the market-based electricity trading system to the grid network is envisaged to reduce the dependency of agents on the aggregator, wherein the present energy management architectures the lack of coordination among actors limits the capability of peer-to-peer trading.Motivated by these studies, this paper exploits the feasibility of applying the blockchain technology to the electricity trading market to develop a transparent and stable power system.The current blockchain primitives can be designed to support public audit and share transactions records without relying on a trusted intermediary.Moreover, since electricity consumption along with the overall power grid performance needs to be optimized, a proof-of-benefit (PoB) consensus mechanism is presented to achieve better economic benefits compared to other consensus mechanisms such as proof-of-work (PoW) and proof-of-stake (PoS) in the grid.
The contribution of this paper are summarized as follows: 1. We develop a Peer-to-Peer Electricity Blockchain Trading (P2PEBT) System to achieve transparent and stable electricity trading.2. We propose a novel consensus primitive-PoB-and a blockchain design that uses it to adapt electricity trading system to stabilize the smart grid system.3. To flatten the power consumption profile, we further propose the benefit index to select the winning block in the consensus mechanism to achieve the minimum power fluctuation.
The remainder of this paper is as follow.In Sect.2, it introduces the state-of-the-art of the blockchain technology and its application in the peer-to-peer electricity trading market compositions.In Sect.3, the concept model is presented for the distributed energy market with components in smart grids.The problem definition and the solution PoB consensus mechanism are proposed in Sect. 4.
Then, security analysis and simulation results for a local area trading platform with the EV market and the concept model evaluation are presented in Sect.5, and the paper is concluded in Sect.6.

State-of-arts of blockchain applications
The blockchain technology promises to provide a shared and secure decentralized ledger for individuals and companies to exchange digital assets and track ownership over a distributed encrypted network [15].The advanced features of blockchain is a genuine combination of several technologies including distributed computing, cryptography, and game theory, where the technological and economic primitives are elegantly considered [16].The data integrity is guaranteed via the nature of the distributed feature.The encryption system that uses public and private keys offer the capabilities for users to sign transactions.Moreover, the consensus mechanism guarantees its robustness against misbehaving and malicious participants and incentivizes participants maintain to validate transactions.Henceforth, the blockchain is a promising technology for broad business sectors where transparency, trust, and efficiency are needed.The author [17] proposed a novel energy trading mechanism based on blockchain technology to adopt the decentralized locally generated electricity.However the blockchain technology in this paper is only used as a database to record transactions.In [18], the authors evaluate the economic features of the market mechanism for local energy trading based on the distributed information and communication technology.A comprehensive internet of thing business model is designed in [19] to enable P2P trade for paid data based on the blockchain and smart contract.However, the trading model does not perfectly adapt to the energy sector trading to address frequent transaction needs and overall system performance consideration.Bitcoin is one of the most widely-used blockchain systems that uses PoW to solve the critical challenge of reaching consensus among participants [20].PoW requires participants to dedicate computation time and energy towards ''work'', where the processes of initiating this consensus protocol are called miners.Miners are required to solve a hash code crypto puzzle before encapsulating the transactions into a new block [21].The miners repeatedly select a nonce which is the difficulty for solving the puzzle to obtain a result lower than the threshold, where the network peers are fighting using their computation source.Undoubtedly, there is a huge waste of energy and requires a constant global effort.Moreover, in order to reduce the number of forks of the chain, Bitcoin's PoW is designed to produce a new block on average of 10 min and the difficulty in mining a new block is increasing.Thus, the recommended waiting frame is 6 blocks before accepting a transaction, which makes it impossible for many applications such as electricity trading [22].
To address the energy consumption waste of PoW consensus mechanism, various alternative consensus mechanisms have been proposed, such as proof-of-stake [23] and proof-of-luck [24].These approaches aim to replace the useless work of solving puzzles by selecting a leader for deciding the next block according to their stake shares or the pure luck of the participants.Though making energy consumption less wasteful, they still require a fair amount of available computation resources.The practical Byzantine fault tolerance algorithm enables a system to reach consensus and proceed transaction within a few network information exchange which against up to onethird participants attack [25].But this algorithm requires the network having the global knowledge of the participants and does not scale in the number of participants.The problem of consensus is that participants of the distributed system must agree on and accept a single shared state [24].In order to adapt the frequent trading demands and consider the global power network delivery quality in the energy sector, an adaptable consensus mechanism is needed.
The QuorumChain developed by JPMorgan Chase executes smart contracts with the Ethereum virtual machine which designs an alternative consensus protocol of the public Ethereum blockchain [26].The smart contract in blockchain is implemented by open-source agreements, which is used by this protocol to validate blocks.In [27], the authors presented the insight of using smart contract to allow the automation of multi-step processes to self-execute the distributed and heavy workflows, which is envisaged in the energy industry and the internet of things.The use of smart contract offers flexibility to implement alternative consensus primitives, which in consequence provides the potential to balance supply and demand in the transactional energy market.
In summary, the uncontrolled EV charging or discharging bahavior may result in instability of the overall grid system operation.In order to adapt frequent trading demands in the smart grids in a secure and efficient way and ensure a robust grid network, it is critical to design a consensus protocol for efficient distributed grid operations on the blockchain based trading platform.
3 Peer-to-peer electricity blockchain trading system model The revolution towards the P2P power exchange system can be achieved predicated on the diminutive-scale energy generators and EVs, where they may produce, consume, and sell excess electricity capacity like a commodity.The hierarchical structure is instead replaced by energy transactions and agreements.In this way, power loads including domestic and business users are capable of connecting to both the retail for end users and wholesale market from the conventional power generators.This paper proposes a peerto-peer electricity trading system that sanctions prosumers to trade energy while ensures the overall network quality with its designed consensus mechanism.

Overview of P2PEBT system
As shown in Fig. 1, in the traditional power grid system (Fig. 1a), the electricity flow is hierarchical and the electricity exchange process relies on the retailers to participate in the price negotiation process.In order to adapt the existing conventional power system, we can refer to the Fig. 1b that we adopt the conventional power delivery system.The system reformation lies in the middle to the low voltage level where the power loads are delegated in microgrid containing renewables, small power storage, and EV.Besides providing the wholesale market in the conventional grid system, transactional energy enables coordination of retail customers utilizing frequent tranching transactions to be executed automatically by blockchain embedded system, consequently reducing the centralized features of the next generation grid system [28].In the P2PEBT system, all components in the microgrids such as domestic users, batteries, solar panels, and EVs are capable of drawing and injecting electricity into the power network.The electricity asset is assumed as a smart property as ownership of this asset can be controlled by smart contracts.The advantage of treating electricity as the smart property is that it can be controlled via digital devices and the asset ownership transfer can be achieved at low cost.For EVs, the charging and discharging process can be realized by a programmable charge installation which enables the instant on/off switching the electricity flow as instructed by EVs (assuming the sophisticated design of switches).The demands for buying and selling electricity is defined as transactions, in which the information is broadcast in the grid system via an appropriate wireless network [29].The transactions can also be executed between retail and wholesale markets which equalizes the opportunity for all components.Moreover, the exchange procedure must account for the transmission and distribution limits and other physical constraints on the grid.
As discussed above, the P2PEBT system conforms to the following rules: 1. Adaptable The fundamental components of the P2PEBT system is taken as the reference to the current market compositions, which also have been modified to adopt the blockchain technology.P2PEBT system remains the integrity of the traditional model and complies to the market rules.2. Efficient The transaction process eliminates the involvement of the third party comparing to the traditional retail process, thus the amount of time consumed is decreased while the efficiency is improved in a transparent exchange way.

Flexible The proposed model deploys an open trading
platform which allows more energy prosumer types to enter the exchange market in a more flexible manner.4. Cost effective The new electricity system builds a direct connection between buyers and sellers while ensuring the overall power network stability, which maximizes the economic return for both the grid system operators and individual users.As depicted in Fig. 2, the microgrid components are the nodes in the P2PEBT system and they are able to publish transactions according to their demands.The demands of buying and selling electricity are encapsulated as transactions in the P2PEBT system, where each transaction period is defined as T round .T round is the time for mining a new block in the blockchain which is defined by the consensus primitives.And each node is capable of setting the price for the electricity transaction to incentivize users to balance the supply and demand, in the meantime, to reduce the power generation and consumption peaks.For each transaction (TX i ! ) that is published by the prosumer i in the P2PEBT system, it is formulated as Eq. ( 1) in the form of a vector.
where the Id i is the identifer for the transaction initiators , the r i is the unit price for the electricity transaction, the Q i is the transaction quantity, and c is a status matrix: 1. Transaction initialization In order to protect users' privacy, the transaction payload is encrypted by the transaction manager where the actual contents of the transaction are presented by hash.In P2PEBT, the transaction details can only be accessed by the deal nodes and the real contents can be revealed by identity registration with the transaction manager.

Transaction aggregation
After completion of order preparation, all transactions are aggregated including the amount of electricity and expected serving time.The system will count the total electricity demands and call the smart contracts to execute energy trading.

Consensus commitment
The consensus mechanism is applied to the transactions to select a leader of the current process.The leader broadcasts block data and its PoB to other authorized nodes.The nodes then audit the block data to see if the hash matches its local records in the nodes hash verification process.If the hash results are matched, nodes will accept the new data block and proceed to the next step.If not, then the new block generation process will be terminated and the system waits for the next round.More details of the PoB mechanism will be given in Sect. 5.

Block generation
The agreed transaction data is then broadcast to the whole network and only participants being selected in the new block are able to decrypt the block contents to execute the transactions.Then the encrypted block contents can be executed in the network.

Problem definition for electricity trading
In this section, we present the problem definition for the amount of electricity for EVs in the P2PEBT system to charge and discharge to minimize the overall power fluctuation in a grid system composed of microgrids.We define that the component in the P2PEBT node with the characteristics of EV that is capable of both drawing and injecting energy into the same entity, and we will refer them as EVs for simplicity.We define that the components in the P2PEBT node can draw and inject energy into the grid.In this paper, we assume all components are EV with the capabilities of drawing and injecting energy into the grid.Within and between each microgrid, the prosumers including EV are denoted as nodes and they are able to draw or inject electricity into the grid.A set of microgrids (denoted as M n ) is indexed by n, where n 2 x :¼ f1; 2; . ..; ng.We denote that a set of charging EVs in M n as v :¼ ðCV n i ji 2 Z; n 2 xÞ; Z ¼ f0; 1; 2; . ..; Ig, where i is the charging EV index and I denotes for the total number of charging EVs.The discharging EVs in M n denoted as w :¼ ðDV n j jj 2 Z; n 2 xÞ; Z ¼ f0; 1; 2; . ..; Jg, where j indexes the discharging EV and J is the total number of discharging EVs.v n;min i and v n;max i are the minimum and maximum electricity charging demands in M n , which correspond to the minimal Fig. 2 Structure of proposed P2PEBT system transaction process energy for EV normal use and battery capacity respectively for CV n i .Then we define v n ij is the power demand of CV n i for directly obtaining electricity from the EV DV n j in M n .The electricity demand vector of CV n i is X n i :¼ fv n ij jj 2 Zg.Considering that we need to satisfy the minimal charging demand for EV, the energy demand (C i ) function at round time t 2 ½1; 2; . ..; T is defined as follows: where t is the electricity charging efficiency in the power exchange process.
For the discharging EV in P2PEBT system, the amount of available electricity supply is o n j from discharging EV DV n j in M n .And the corresponding electricity supply vector is O n j :¼ fo n j jj 2 Zg.Then we can define the maximum electricity supply (H j ) from discharging devices at round time t 2 ½1; 2; . ..; T as follows: whereis the discharging efficiency taking into account of transmission line loss.Furthermore, we define the electricity consumption from the microgrid M n at round time t as P n ðtÞ, where P n ðtÞ excludes the charging and discharging loads from EVs.Since we aim to minimize the overall electricity consumption fluctuation to increase the smart grid stability, the consumption curve of a day should be as gentle as possible to achieve power balance.The objective function is to minimize the variance of slope for a period of electricity exchange, thus to achieve the network power balance.We first define the overall grid power fluctuation amount with respect to time as follows: then the slope of the power fluctuation curve is the derivative of the function HðtÞ which can be represented as follows: Finally, the objective function can be represented as the variance of the slope function l(t) as follows: The first constraint ensures that there is sufficient amount of charging electricity for EV to use.Then we constrain that all EV power demands shall be considered so that the charging amount is greater than 0. In the third constraint, the amount of discharging power to be optimized shall not exceed the electricity amount from the transaction records.At last, we set the amount of discharging power from EV with consideration of the power loss is completely absorbed to guarantee the energy efficiency.By taking the second derivative of the objective function, we can obtain the following functions: The objective function in (10) is strictly convex with the constraints, thus there exists a unique optimal solution as the result of the second derivative is greater than 0. The optimal solution for the objective function is denoted in the Eq. ( 11), where T is defined by the total round number for the electricity exchange and P n ðt À 1Þ is the last round electricity consumption by other loads in the microgrid.And the reciprocal of the result of the objective function is used as the benefit for this transaction k.
4 Proposed proof-of-benefit consensus mechanism In this section, a proof-of-benefit consensus mechanism is proposed to proceed the transactions for P2PEBT system in order to minimize the objective function.In this consensus mechanism protocol, participants are the main principals who are required to perform routines to maintain and extend the blockchain.Participants of the trading system rely on the blockchain to execute the transactions.The matching and execution processes are implemented via the grid infrastructure settings.According to the proposed P2PEBT system, the charging and discharging EVs need to submit the transactions with the required inputs.The calculation process of solving the overall benefit problem is completed in each node's local network, where the result is then uploaded along with the launch of the proposed blockchain protocol.
As described in Algorithm 1, there are two parts of functions which are the round preparation and mining execution respectively.At the beginning of each round, peers in the network prepare to mine on a particular chain by calling the function PoBRound and pass the latest block in the network.The mining process is executed after waiting a specified round time when the nodes call the function PoBMine to mine a new block.The node passes the header of the latest and last block to be extended (previousBlock).In this process, we have to make sure that the previousBlock and the roundBlock have the same parent and each node needs to wait for mandatory ROUND-TIME for choosing the most beneficial block for the grid system.Then a benefit value is generated in the local network based on the benefit number calculated from the objective function result, which is then used to determine the winning block with transactions to be executed in the next round.A higher benefit value means that the charging and discharging schedules have a more positive impact on the overall grid performance.Furthermore, a monotonic counter is used to prevent concurrent invocations between the network peers.
In the Algorithm 2, the details to execute transactions are described.Each node in the network receives transactions from other nodes and maintains a copy of the current chain with labeled blocks.In every round, nodes call the function IMPLEMENT to proceed the pending transactions into a new block and generate a proof along with it.Then the new chain is broadcast to the network peers, in the meantime, where the chain with more benefits will be accepted if received.
The nodes will return an updated chain with the new block from the set of new transactions after executing function IMPLEMENT.The newBlock contains the hash value of root (parent) blocks, the new block made from newTXs and a proof of benefit (proof).In the function BENEFIT, it computes the overall benefits of the chain by summing up the benefit value (proof) so that we can use it to determine the authenticate blockchain with the highest benefit value.In this way, it will incentivize the system nodes to act more desirable to contribute to the overall grid performance.
In a complete execution process, each node starts with an empty blockchain, a set of pending transactions and an initial empty roundBlock.After initializing the states, nodes listen for the transactions from the network.When receiving transactions from the network, the node adds them to the block and broadcast to the network peers.Before the start of each new round, the node calls again the function PoBROUND to bind mining to the current up-todate chain and start the next round after waiting the required timeframe roundTime.

Analysis
In this section, we present the security analysis of the proposed PoB consensus mechanism used in the P2PEBT system and numerical results for the power fluctuation performance after applying our electricity trading strategy.

Security analysis
P2PEBT system is designed to adapt to the electricity trading demands, where transaction and processing time should be controlled.In the meantime, we need to ensure the privacy of nodes so that the transaction data cannot be accessed by the third party.Furthermore, the system has ability against potential traditional security attacks via standard cryptographic primitives.Hence, we analyze the security aspect of our PoB consensus-based P2PEBT system.
1. Control of blocks: Consider a set of participants a 2 ðCV n i ; DV n j Þ, all the charging and discharging vehicles in microgrids CV n i ; DV n j 2 M n .The wellbehaved nodes will act according to the PoB consensus mechanism where they are supposed to append the longest chain, and the new chain with the largest benefit value k will be chosen as the newly added block.During each round, each node will obtain the proof which includes the benefit value based on the pre-defined algorithms.Hence, the number of new blocks that are mined by a set of nodes a is proportional to the number of nodes in a.

Round and processing time:
We propose a ROUNDTIME of 5 min, where the block confirmation time is slightly larger than 5 min.Compared to the Bitcoin blockchain, the block confirmation time is 10 min which cannot meet the requirement for frequent trading commands from participants.Furthermore, the confirmation time is longer than the Ethereum network which is normally 15 s as we need to ensure the minimal time frame for the charging and discharging process.Thus, we have chosen this value based on an evaluation of block propagation time in those networks.In the block processing time, the selection of the winning block with maximal benefit can be implemented without transmitting the complete block, and only after the winner is determined should the whole block be transmitted.3. Data integrity: In P2PEBT system, we rely on the transaction manager to encrypt the transaction contents into the hash value so that the transaction contents cannot be accessed by the third party.Without corresponding keys for the hash value, a potential attacker cannot alter the contents of the transaction.
The decentralized nature of the blockchain features on the data unforgeable as all transactions require digital signatures and the only way to corrupt the network is to gain the majority (51%) computing power of the system resources.

Numerical results
We evaluate the performance of the proposed PoB consensus mechanism for P2PEBT system based on the Austrian residential power consumption data from Europe Network of Transmission System Operators for Electricity [30].A residential area with 200 households within one microgrid with the power capacity of 800 kW is considered to simulate the EV-integrated electricity trading system (N = 1).We assume that the initial number of EV in the area to be 100.According to [31], there are mainly three charging types, up to 3 kW for slow charging, 7-22 kW for fast charging points, and 43, 50, or 120 kW for rapid charging units, where the charging speed depends on the connector types.The PoB mechanism is implemented using Python to execute the charging and discharging orders.We randomly generate the transaction demands according to the distribution of charging unit types and assign them to the charging and discharging transactions.The transactions are in chronological order in which the older transactions have higher priority in the execution process.Moreover, the EV charge connection status is modeled as two parts in halfhour manner according to the charging demand distribution throughout a day [32].Then we randomly generate the EV connection profile where the number of transactions is the total number of connected EVs in each time slot.And the number of charging and discharging transactions are set to be 2:1.The optimization problem is strictly convex, so the optimal results can be obtained by obtaining the global maximum benefit number with the PoB mechanism.
The daily residential power consumption served as an input to the P2PEBT-enabled system with PoB consensus mechanism for simulation; more precisely as the consumption forecast for each round calculation.In each round iteration, the P2PEBT system refers to the power consumption quantity from the last time slot and calculates the overall power consumption curve slope accordingly.In Fig. 3, it demonstrates the charging and discharging electricity demand changes after applying the P2PEBT system, where we can infer the system ability to optimize the 24-h electricity flow.The blue bars are the charging and discharging demands sent from the EVs in each time slot respectively, where the green bars are the demand quantity after optimization in the P2PEBT system.The results are shown as aggregation quantity in each time slot (1 h) in a day with arbitrarily generated power demands.For example, in hour 1, the simulation result shows the effect of the PoB consensus mechanism on the electricity transaction execution.Note that we assume each transaction has a maximal waiting for two rounds which means that the transaction will be enforced to execute after two rounds to ensure that the system does not intervene EV owner's daily routine, so the total amount of transaction quantity is ensured in this process.The darker blue and green bars represent the demands before optimization, where we can see clear peaks at 07:00-09:00 and 18:00-21:00 corresponding to the work hours, reflecting market consistency.As shown in Fig. 4, it depicts the objective function PF value from Sect. 3 to quantify the power fluctuation level with and without the P2PEBT system.The black line with circle mark is the PF value without the P2PEBT system, where the value is calculated from the last 24-h power consumption profile with the electricity demands from EV charging and discharging.The red dashed line with asterisk mark is the PF value in a day which the value changes based on the different charging and discharging demands fed from the EV users.We can see that the PF value with P2PEBT system is more stable and shows a much lower PF value by the end of the day.Moreover, the trend of the PF value change is generally growing as the number of EVs in the microgrid has limited capability to stabilize the system.
In the Fig. 5, it shows the overall power consumption including the charging transactions that consume electricity, discharging transactions that inject electricity back to the grid and the residential power loads.According to Eq. ( 7), we can calculate the cube root of the PF value which is 48.5.With the proposed PoB consensus mechanism enabled P2PEBT system, EV can trade electricity through placing charging or discharging transactions to the market concerning their connection statuses, charging connector types and charging/discharging constraints.This enables the reduction of the overall power consumption fluctuation level where the optimized result PF with the proposed system is 32.4,which is 33.2% lower compared to the result without optmization.We can infer that the system uses the last time slot electricity consumption data to schedule the charging and discharging transactions have significantly flattened the overall power consumption curve which will increase the stability of the smart grid.In this case, the cost for starting the subsidiary generators (power generators with less response time) to supplement the power consumption can be reduced.

Conclusion
The electricity industry is undergoing major evolutions that works far more than the infrastructure upgrade, where people focus more on renewable and sustainable energy.In this paper, we proposed a proof-of-benefit consensus protocol in blockchain system and further presented the P2PEBT system that works with EV in the electricity Wireless Networks (2021) 27:4217-4228 market to minimize the power fluctuation in a day.By achieving the objective, the stability is enhanced with more flattened power consumption and the operation cost is accordingly reduced corresponding to the emergent situation operation.We analyzed the state-of-art blockchain technology and the consensus mechanisms including proofof-work and proof-of-stake where the motivation is identified with respect to the disadvantages in these mechanisms.Then, the PoB is proposed along with the P2PEBT system to support EV participating in the electricity trading with local peers.Security analysis has shown that the proposed mechanism is capable of protecting the transaction execution against potential attacks and adapting to the electricity trading scenario.Simulation results present the charging and discharging demand changes using the P2PEBT system and further implies the capability of the proposed system in substantially decreasing the PF value.
We use the real dataset from Austrian households to analyze the customer electricity consumption behavior and currently available charging speed types are adapted to simulate the proposed system.The P2PEBT system provides a brand new way to practice the transactional energy market, and the blockchain technology not only decentralizes the hierarchical power grid system but also increases the system security.In the future, it is necessary to implement the system in the blockchain platform to feed with real-time data in order to test its scalability and performance.
Open Access This article is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creative commons.org/licenses/by/4.0/),which permits unrestricted use, distribution, and reproduction in any medium, provided you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license, and indicate if changes were made.

Fig. 1
Fig. 1 Electricity trading system model comparison.a Traditional hierarchical power distribution system.b Proposed decentralized power exchange system with microgrids

Fig. 3
Fig. 3 Charging and discharging demands collected from EVs in 24 h

Fig. 4
Fig.4PF value of the overall power grid with and without P2PEBT system

Fig. 5
Fig. 5 Power consumption profile in a residential area