Consortium Blockchain-Based Microgrid Market Transaction Research

: The microgrid trading market can e ﬀ ectively solve the problem of in-situ consumption of distributed energy and reduce the impact of distributed generation (DG) on the grid. However, the traditional microgrid trading model has some shortcomings, such as high operation cost and poor security. Therefore, in this paper, a microgrid market trading model was developed using consortium blockchain technology and Nash game equilibrium theory. Firstly, blockchain container is used to authenticate the users who want to participate in the transaction. Then, the pricing system collects and integrates transaction requests submitted by users, then formulates transaction pricing strategy of microgrid using Nash equilibrium theory. Finally, the price, trading volume, and user information are submitted to the blockchain container for transaction matching to achieve the transaction. After the transaction is completed, its related information is recorded in the hyperledger and the dispatch system is called. The scene simulation was implemented on Fabric 1.1 platform and the results analyzed. Results show that the trading model proposed in this paper greatly reduces the cost of electricity purchase and improves the beneﬁts of electricity sales. Besides, the model is far more capable of handling transactions than the models based on Bitcoin and Ethereum.


Introduction
With the gradual depletion of energy resources and deterioration of the environment, energy development is facing the challenge of clean utilization and high efficiency. Renewable energy, including wind power, photovoltaic power (PV), hydropower, and biomass power generation is vigorously promoted by the development of energy transformation [1]. Although the traditional centralized power generation and long-distance transmission of the power grid are stable, there are also problems such as inflexible unit start-up, high transmission cost, and single power supply form [2]. In order to optimize the grid structure and solve the problem of distributed energy in-situ consumption and instability, the microgrid composed of distributed power sources, energy storage devices, energy conversion devices, loads, monitoring, and protection devices have been vigorously developed [3,4]. The development of microgrids can promote distributed power utilization, reduce centralized power supply capacity and losses, and improve grid peak-to-valley performance, thus achieving demand-side management (DSM) and efficient utilization of resources [1]. Among them, the microgrid market provides a platform for small-scale consumers to exchange local energy, which is an essential link in the operation and development of microgrid [5]. Therefore, how to develop a flexible, efficient, and secure microgrid trading platform is of great significance in the development of microgrids and even renewable energy.
The microgrid market can promote the balance of power generation and consumption in the region and solve the problem of local consumption of distributed energy [6,7]. Therefore, in order to promote the development of the microgrid market, scholars in related fields have conducted in-depth research on the microgrid market business model [8], trading mechanism [9][10][11][12][13], and market model [14,15]. In [15], a bargain-based energy trading market was designed. A decentralized algorithm was proposed to develop a bargaining system, and the impact of this energy trading model on the transaction cost of microgrid was analyzed. Most of these studies focus on the market mechanism under the traditional trading model of a single transaction and intermediary supervision. Through intermediaries and other institutions, management costs are relatively high.
With the rapid growth of the global microgrid market, the addition of energy storage technology has made the market entity involved in microgrid market transaction diversified. Market entities begin to shift from producers or consumers to prosumer. The decentralized trading model can effectively reduce the management and operation costs of the energy market, so it has attracted full attention and has been applied to the research of the microgrid market [8, 16,17]. In [18], a hierarchical architecture model was proposed, and a peer-to-peer (P2P) energy trading platform based on game theory was developed. However, with the development of energy transaction mode towards decentralized mode, there are some hidden dangers of information security. User information and transaction data are easily tampered with, and information security cannot be effectively guaranteed. Promoting the decentralized transaction mode of the microgrid, reducing the operation cost of the microgrid market, and ensuring the security of microgrid transaction information are the new directions of microgrid market research. Therefore, new technologies are needed to support them.
Blockchain is a decentralized solution that does not require any third-party organization. Besides, the nodes in the blockchain are anonymous, which makes other nodes more secure to confirm transactions [5]. Through continuous exploration, scholars have found that blockchain technology has the characteristics of decentralization and tamper-resistant, which can reduce the operation cost of microgrid market, it can ensure the security of microgrid transaction and make the transaction process of microgrid market more transparent [19][20][21]. In [19], seven components based on blockchain technology were introduced, and an efficient energy market framework for microgrid was developed. Then, the Brooklyn microgrid project was evaluated based on the required components. In [21], an information flow trading model using blockchain was developed. At the same time, ant colony optimization algorithm was improved by improving pheromone concentration and adjusting parameters to solve the trading model of the microgrid group. At present, these studies are more focused on market competition strategy or goal optimization. Few studies have carried out specific analysis and experimental simulation of microgrid transactions based on blockchain technology. Besides, in the early stage of blockchain technology research, the implementation platform of this technology mainly relies on Bitcoin and Ethereum [22,23]. These two technologies have strong transaction processing ability and can make the transaction process more transparent, but they require higher cost and have poor privacy. The consortium blockchain technology is a blockchain technology with authorized nodes [24,25]. This technology has low energy consumption, secure privacy, and is suitable for small community-based power systems.
Developing an energy trading system, in addition to advanced technology as a support, also requires a matching approach to develop a flexible market mechanism to achieve micro-grid market transactions. The key to studying the trading mechanism of microgrid market is the mutual competition behavior of different stakeholders in the market, and the Nash equilibrium theory is an excellent method to solve this kind of problem [26][27][28]. The application of this method in the research of microgrid trading market has essential theoretical and practical significance. In summary, according to the characteristics of diversification of microgrid market participants, the pricing strategy of microgrid transaction market based on Nash equilibrium theory is proposed in this paper. At the same time, in order to achieve decentralized transaction and ensure the security of information and data, the microgrid market trading system is developed using the consortium blockchain technology in this paper. The trading model proposed in this paper can improve flexibility and efficiency in the microgrid trading process, and ensure transaction security. More specifically, the contributions of our work are: (1) A novel pricing strategy for microgrid market transactions is proposed based on Bayesian-Nash equilibrium theory. In this paper, the pricing strategy of the microgrid market is formulated based on the Bayesian-Nash equilibrium theory, with the goal of low purchase cost and high sales efficiency. The proposed pricing strategy can effectively improve the efficiency of electricity sales and reduce the cost of electricity purchases. (2) The microgrid market trading model is developed using consortium blockchain technology.
In this paper, the trading model of microgrid market is developed by combining the consortium blockchain technology with the pricing strategy proposed, and the simulation experiment is carried out. The trading model of microgrid market proposed in this paper can realize decentralized trading mode, increase the interests of microgrid users, and ensure the security of transaction information and transparency of transaction process. At the same time, the energy trading platform can effectively solve the problem of local consumption of distributed energy. (3) Four chaincodes are developed, including the identity verification unit chaincode, buyer/seller unit (BU/SU) chaincode, matchmaking transaction chaincode, and transaction compensation chaincode. The chaincodes are deployed in Hyperledger Fabric 1.1 platform to simulate the transaction authentication process. Compared with Ethereum and Bitcoin, the method proposed in this paper is more efficient in dealing with transactions, thus shortening the time of trading in the microgrid market.
The paper is organized as follows: Section 2 introduces related work on Nash equilibrium theory and blockchain technology. Section 3 presents the relevant methods and the trading model of the microgrid market using consortium blockchain. Section 4 shows a case, then simulates the text model, and further analyzes the feasibility of the model based on the simulation results. Section 5 gives the conclusions and future work.

Related Work
In this section, we review related works about the microgrid market and the application of blockchain technology in the microgrid.

Microgrid Trading Market
With development of the economy, demand for electricity is seeing a sharp increase. Distributed generation (DG) can reduce the distance of power transmission and improve energy efficiency. At the same time, DG incorporates a large number of renewable energy sources such as wind power and PV, providing a platform for the use of clean energy. Although the DG has many advantages, the development of DG has been hampered by the high cost of single-machine access and poor controllability. In order to solve the problems of DG and promote its development, a "microgrid" is proposed [29]. The microgrid market can provide a trading platform for consumers and generators in the local community to effectively address the local consumption of DG and promote the efficient use of clean energy. In addition, the microgrid market can mitigate the impact of DG on the grid and reduce losses caused by long-distance transmission [18]. Therefore, the researches on the microgrid market have attracted the attention of scholars in the industry.
Microgrid is a typical representative of the transition from traditional power system to smart grid. In the early stage of microgrid market research, the microgrid market entrusted intermediary operators to operate and manage [24,25,30]. In [31], an optimization scheme based on a multi-agent system is proposed to solve the problem of a decentralized operation of microgrid.
The microgrid market trading platform is gradually moving towards a decentralized trading model [32,33]. In [34], a two-layer hybrid model (BI-HMOEA) was proposed based on the Stackelberg game model, and an open energy market model was developed. The model can reduce energy consumption while reducing carbon emissions. In [35], a decentralized electricity trading market was designed based on the battery function, and the linear optimization model is used to save the local electricity cost to the greatest extent. The decentralized trading model can save operating costs in the microgrid market. However, issues of trust and security are great challenges for decentralized transactions.

Application of Blockchain Technology in Microgrid
Blockchain technology is a new application mode of computer technology such as distributed data storage, P2P, consensus mechanism, and encryption algorithm. The essence of blockchain is a globally shared distributed ledger. By establishing a distributed trust mechanism through self-certification, it can maintain a growing list of data records. The method has the characteristics of decentralization, high credibility, and data cannot be tampered [36]. In view of this, blockchain technology can be used as a powerful technical support for decentralized transaction mode. It can reduce the cost of market operations and enhance the security and transparency of user information and transaction data. In recent years, blockchain technology has been applied in the research of finance [37][38][39], supply-chains [40,41], medical care [42][43][44], and smart cities [45,46]. With the deepening of research on blockchain technology, the technology is gradually being applied in smart grids [47][48][49][50][51].
Applying blockchain technology to distribution network technology operation is a relatively new research direction [52][53][54]. In [50], blockchain technology was used to provide ancillary services to the microgrid market, taking into account technical issues that may arise during the decentralized transaction of the microgrid. The decentralized trading model has become one of the trends in smart grid development. However, the decentralized trading model also faces security challenges while saving operating costs and improving operational efficiency. In this case, blockchain technology has become the most powerful technical support for building a power trading system [51,53,55].
In recent years, the research of block chains has focused more on Bitcoin and Ethereum [56]. In [56], Ethereum was used to build a renewable energy trading platform. The advantage of the complete decentralization of the public blockchain is undoubtedly a huge innovation in the way distributed nodes communicate. However, the way in which public blockchain are completely anonymized and open. Therefore, public blockchain is not applicable to distributed energy transactions. The consortium blockchain can be supervised by controlling the authority of the accounting nodes participating in the consensus. Its low development cost and secure privacy make it suitable for small energy systems such as microgrid [57][58][59]. In [59], an energy trading framework was proposed using consortium blockchain technology and used in different scenarios of the Internet of Things (IoT).

Microgrid Market Trading Model Using Consortium Blockchain Technology
In this section, a microgrid market trading model based on the consortium blockchain technology is developed. First, the related technologies involved in the model are introduced. Then, the development process of the microgrid trading system based on the alliance blockchain technology is described in detail.

Related Technology Introduction
This section presents the Bayesian-Nash equilibrium theory, consortium blockchain technology involved in developing the trading model of microgrid market. In the microgrid, the order of user's strategies does not affect game results, and information is not fully available. Therefore, Bayesian-Nash equilibrium theory is chosen to develop a microgrid pricing strategy.
There are n individuals participate in the static game G [28]: G = A 1 , · · · A n ; θ 1 , · · · , θ n ; pr 1 , · · · , pr n ; u 1 , · · · , u n (1) The strategy combination of Bayesian-Nash equilibrium solutions has the characteristics of type dependence, in which each participant i relies on the strategy θ i of the other participant type-dependent strategy a * i (θ −i ) in the case of maximizing the self-utility function u i . That is, the strategy combination a * = (a * 1 (θ 1 ), · · · a * n (θ n )) is a Bayesian-Nash equilibrium, for any i,

Consortium Blockchain
The concept of blockchain was first proposed by Satoshi Nakamoto in 2008 [60]. In recent years, the attitude of the world towards Bitcoin has risen and fallen, but as one of the bottom technologies of Bitcoin, blockchain technology has been paid more and more attention [61].
At present, according to the degree of decentralization, blockchain technology can be classified into three categories: public blockchain, consortium blockchain and private blockchain. In the public blockchain, any individual or group can send transactions, and anyone can participate in the consensus process. However, the public blockchain is energy-intensive and uncontrollable. Private blockchain only uses the general ledger technology of blockchain to keep accounts, generally used in an enterprise or institution [62].
Blockchain in which multiple nodes are selected from a group or industry as accounting nodes are called consortium blockchain. Different from all nodes in the public blockchain participating in the consensus process, only pre-selected accounting nodes participate in the consensus process of the consortium blockchain, while other nodes can participate in the transaction, but not in the accounting process. It has both privacy of private blockchain and decentralized thinking of public blockchain, so consortium blockchain has the following characteristics [57,62]: (1) Low transaction cost and fast speed: some nodes participate in verification and accounting during the transaction process, and a small number of consortium nodes have high credibility, which simplifies the authentication process and makes it faster than the public blockchain. (2) High security of data information: different from the public blockchain, participants in the consortium have access to the data of the consortium blockchain. Access is restricted to provide better privacy protection. (3) Controllability: the consortium blockchain has the advantage of expandability in the short term, and has a certain degree of regulation.
Private chains are not suitable for microgrid because there are multiple market entities involved in microgrid transaction. On the other hand, the microgrid is not the same as the power grid, and the number of market entities in microgrid transaction is much smaller than that of the power grid. At the same time, market entities need to have specific qualifications to conduct transaction, so the consortium blockchain is more suitable for the research of microgrid transaction market.

Hyperledger Fabric
Hyperledger Fabric is the foundation platform of the consortium blockchain, an open source project initiated by the Linux Foundation in 2015, which is mainly used to promote blockchain digital technology and transaction verification. Hyperledger Fabric is not a completely open system, and access to the network requires authorization.
Fabric adopts a modular design in the architecture, which is mainly composed of three service modules: membership services, blockchain services and chaincode services, as shown in Figure 1. Membership services provide membership registration, identity protection, content protection, and transaction auditing functions to ensure platform access security and rights management. Blockchain services are used for formula management of nodes, distributed calculation and storage of ledgers, and implementation of P2P protocol functions between nodes. It is the core component of the blockchain and provides the underlying support for the main function of the blockchain. The chaincode services provides an execution engine for smart contracts, providing a deployment environment for contract code programs [63]. The chaincode can be developed in a variety of programming languages, including Go, Java, Node.js. Currently, the most well-supported is the chaincode written in Go. Hyperledger Fabric is the foundation platform of the consortium blockchain, an open source project initiated by the Linux Foundation in 2015, which is mainly used to promote blockchain digital technology and transaction verification. Hyperledger Fabric is not a completely open system, and access to the network requires authorization.
Fabric adopts a modular design in the architecture, which is mainly composed of three service modules: membership services, blockchain services and chaincode services, as shown in Figure 1. Membership services provide membership registration, identity protection, content protection, and transaction auditing functions to ensure platform access security and rights management. Blockchain services are used for formula management of nodes, distributed calculation and storage of ledgers, and implementation of P2P protocol functions between nodes. It is the core component of the blockchain and provides the underlying support for the main function of the blockchain. The chaincode services provides an execution engine for smart contracts, providing a deployment environment for contract code programs [63]. The chaincode can be developed in a variety of programming languages, including Go, Java, Node.js. Currently, the most well-supported is the chaincode written in Go. Fabric 1.1 supports three consensus algorithms, including distributed queue (Kafka), simple Byzantine fault tolerance (SBFT), and single node consensus (Solo). Kafka is a high-throughput distributed publishing messaging system with multiple sorting nodes, which avoid single-point failures and cause the entire network to crash. SBFT handles transactions faster and has better scalability. Solo is a sort method completed in a single node, which is easy to be implemented and is suitable for simulation in a simple experimental environment [64,65].

The Trading Model of Microgrid Market Using Consortium Blockchain
In this section, the microgrid market trading model is developed using consortium blockchain technology. First, the overall model framework is introduced, and then a trading strategy based on Bayesian-Nash equilibrium is proposed. Finally, according to the transaction strategy and transaction mode, the smart contract is compiled to develop the trading model using the consortium blockchain and Nash game equilibrium theory.

Overall Structure
The trading model of the microgrid market is hour-ahead trading, and the overall model structure is shown in Figure 2. The core of the transaction mainly consists of two parts: pricing system and blockchain container. In pricing system, the transaction price and transaction volume are formulated through the proposed pricing strategy according to the transaction request. In the Fabric 1.1 supports three consensus algorithms, including distributed queue (Kafka), simple Byzantine fault tolerance (SBFT), and single node consensus (Solo). Kafka is a high-throughput distributed publishing messaging system with multiple sorting nodes, which avoid single-point failures and cause the entire network to crash. SBFT handles transactions faster and has better scalability. Solo is a sort method completed in a single node, which is easy to be implemented and is suitable for simulation in a simple experimental environment [64,65].

The Trading Model of Microgrid Market Using Consortium Blockchain
In this section, the microgrid market trading model is developed using consortium blockchain technology. First, the overall model framework is introduced, and then a trading strategy based on Bayesian-Nash equilibrium is proposed. Finally, according to the transaction strategy and transaction mode, the smart contract is compiled to develop the trading model using the consortium blockchain and Nash game equilibrium theory.

Overall Structure
The trading model of the microgrid market is hour-ahead trading, and the overall model structure is shown in Figure 2. The core of the transaction mainly consists of two parts: pricing system and blockchain container. In pricing system, the transaction price and transaction volume are formulated through the proposed pricing strategy according to the transaction request. In the blockchain container, the transactions are matched in the matchmaking transaction center (MTC) and then the transactions are checked in the transaction compensation system. Finally, transactions are submitted to the ordering service (OS) for a transaction order, which be recorded to the ledger and settle the transactions. market entities was published.
(2) Pricing strategy stage: the microgrid has multiple market entities, including users and DGs.
According to the Bayesian-Nash equilibrium theory of incomplete information static game, the transaction price and transaction volume are determined. (3) Transaction execution stage: the transaction information is sent to the Blockchain Container, and the transaction is matched in the MTC. Then users sign the smart contract according to price and transaction volume. Then the transaction information is submitted to the OS for a transaction order, which will be recorded to the ledger and complete the transaction authentication. (4) Transaction compensation phase: this phase calculates and compensates the difference between supply and demand and generation error by establishing a connection with the power grid. (5) Settlement stage: when the transaction is completed, transaction data is recorded and settled, then the Dispatch System is called to complete the energy dispatch.

Pricing Strategy of Microgrid Using Bayesian-Nash Equilibrium
According to users load historical data and DGs power prediction data in the microgrid, the user load and the power generation output power of each transaction period in the next transaction operation period can be found. The power load of user i during trading period t is indicated as follows [66]: where, n is the number of users in the microgrid. It is assumed that one trading cycle is 24 hours and the trading period is 1 hour. According to the configuration parameters of the DG and the external conditions, the output power of DG can be predicted. The prediction result can be depicted as follows: (1) Certification stage of market entities: each market entity was applied for identity and verifies whether it is qualified to enter the market for trading. The demand information of verified market entities was published. (2) Pricing strategy stage: the microgrid has multiple market entities, including users and DGs.
According to the Bayesian-Nash equilibrium theory of incomplete information static game, the transaction price and transaction volume are determined. (3) Transaction execution stage: the transaction information is sent to the Blockchain Container, and the transaction is matched in the MTC. Then users sign the smart contract according to price and transaction volume. Then the transaction information is submitted to the OS for a transaction order, which will be recorded to the ledger and complete the transaction authentication. (4) Transaction compensation phase: this phase calculates and compensates the difference between supply and demand and generation error by establishing a connection with the power grid. (5) Settlement stage: when the transaction is completed, transaction data is recorded and settled, then the Dispatch System is called to complete the energy dispatch.

Pricing Strategy of Microgrid Using Bayesian-Nash Equilibrium
According to users load historical data and DGs power prediction data in the microgrid, the user load and the power generation output power of each transaction period in the next transaction operation period can be found. The power load of user i during trading period t is indicated as follows [66]: e L,i = e 1 L,i , e 2 L,i , · · · , e t L,i i = 1, 2, · · · , n; t = 1, 2, · · · , 24 where, n is the number of users in the microgrid. It is assumed that one trading cycle is 24 h and the trading period is 1 h. According to the configuration parameters of the DG and the external conditions, the output power of DG can be predicted. The prediction result can be depicted as follows: where, the symbol refers to the same as above.
The net output power of user i during the trading period t is indicated as follows: e t NOP,i = e t DG,i − e t L,i i = 1, 2, · · · , n; t = 1, 2, · · · , 24 Therefore, the net output power of user i during the transaction cycle is depicted as follows: e NOP,i = e 1 NOP,i , e 2 NOP,i , · · · , e t NOP,i i = 1, 2, · · · , n; t = 1, 2, · · · , 24 The net output power of the microgrid is expressed as: In this paper, the operating mode of the microgrid is the grid-connected microgrid. Users in the microgrid change roles according to their needs. When e net < 0, the buyers and sellers in the microgrid play a game to determine the optimal price and the amount of electricity traded. At the same time, the sellers adjust their electricity load e L,i to obtain more benefits. Then electricity is traded, and the insufficient power is supplemented by the grid.
During the trading period t, the microgrid users can be classified into two categories: the seller and the buyer. N is the collection of all users in the microgrid, N b is the collection of power buyer, and N s is the collection of power sellers. When e NOP,i ≥ 0, the user is a buyer, which is denoted as j, j ∈ N b ; when e NOP,i < 0, the user is a seller, denoted as i, i ∈ N s . The transaction principle of grid-connected microgrid is to give priority to the internal user needs of microgrid. In the case of insufficient power in the microgrid, users purchase from the grid, and if there is residual power in the micro-grid, the grid will purchase. Therefore, the internal price of microgrid fluctuates with operation of the microgrid and the supply and demand of power in each period. The internal price of microgrid should satisfy the following conditions: p s < p t < p b t = 1, 2, · · · , 24 where, p t is the internal electricity price of the microgrid in period t, p s is the price of "surplus power to the grid", and p b is the price of electricity sold by the grid. In order to facilitate the description of the strategy model, the subsequent analysis defaults to a trading period t. Sellers will adjust their electricity consumption behavior to obtain higher benefits. Therefore, the benefit function of sellers is introduced, which is indicated as follows: where, u i is the benefit of the seller i in period t, and λ i is the adjustment coefficient of the seller's consumption behavior, p is the electricity price in the microgrid. For buyers, the lowest purchase cost is expected. The purchasing cost of the buyer comes from the purchasing of electricity in microgrid and power grid. Therefore, the purchasing cost of the buyer is expressed as follows: C j = q j p + (e L,j − e DG,j − q j )p b j ∈ N b (10) where q j is the amount of power purchased by the buyer j from the microgrid in period t, and 0 ≤ q j ≤ e L,j − e DG,j . To summarize, the buyer and seller in a microgrid constitute a multi-participant game model. The game model is expressed as follows: where, the seller group N s adjusts the electricity consumption plan according to the electricity price. E i is the strategy set of electricity consumption e L,i of the seller i, P is the strategy set of internal price of power in the microgrid, C T is the total cost of power purchasing by buyers in the microgrid, which is described as follows: The purchased electricity quantity q j of the buyer j is as follows: Buyers expect the lowest cost of electricity purchase, and sellers expect a maximum benefit from electricity sales. Therefore, the equilibrium of the game model G is the optimal solution to the problem. By finding the optimal solution, the optimal price can be obtained, and then the power consumers adjust the power consumption strategy according to the price. Therefore, the strategic equilibrium (e * , p * ) in period t of the Nash equilibrium game G is the equilibrium point of the game G, if and only if e and p satisfy the following conditions: C t (e * , p * ) ≤ C t (e * , p) ∀p ∈ P where e * = [e L,1 , e L,2 , · · · , e L,N s ], e * −i = [e L,1 , e L,2 , · · · , e L,i−1 , e L,i+1 , · · · , e L,N s ]. When e net ≥ 0, that is the generating power of the microgrid is a surplus, then electricity is sold to customers at the price of compromise transaction price p a = p s +p b 2 , and the surplus power is sold to the grid at the price of p s .

Deployment of Smart Contracts
In this paper, the consortium blockchain technology is selected to develop the trading model of the microgrid market, and the smart contracts are deployed in the Fabric platform in the form of chaincode. Therefore, in this section, four chaincode stages are deployed, including the user authentication stage, supply and demand information release stage, and transaction matching stage, transaction compensation stage. Corresponding to the four chain codes built on Hyperledger Fabric 1.1, including authentication unit chaincode, buyer/seller unit (BU/SU) chaincode, and matchmaking transaction chaincode, transaction compensation chaincode.

Authentication Unit Chaincode
The contract is used to confirm whether the buyer and the seller are eligible to participate in the microgrid market transaction, and strictly examine the qualifications and identities of users. The contract input is the basic information submitted by the user applying to enter the microgrid market transaction. The basic information that needs to be audited by the BU includes the type of the power purchase user, the real name and identification number (ID) of the legal person or representative of the buyers, the credit record and the purpose of the power purchase. The basic information that needs to be audited by the SU includes the type of DG, the real name and ID of the legal person or representative of the user, the installed capacity and the credit record. The contract output is identity authentication information in a specific format. The basic elements of BU chaincode and SU chaincode are shown in Tables 1 and 2.

BU/SU Chaincode
The chaincode is used to collect the energy demand information of the BU and the information of the SU, then distribute it all to the network. The chaincode inputs of the BU are the expected delivery time of the BU, the account address, and users' ID of the BU. The input information is collected and integrated as user demand information with a specific format by the chaincode. The chaincode collects the above input information, then calls the private key of the BU to sign the integrated information. The chaincode output is the energy demand information with the user's signature. Chaincode allows the BU to modify or withdraw the published information in a short time after release. The chaincode's elements are shown in Table 3. The inputs of the SU chaincode are the total amount of electricity required by the BU, the amount of electricity sold by the SU, the price of electricity, the account address of the SU, and the user ID for a certain period of time. The chaincode integrates the above input information and calls private key of the SU to sign the integrated information. The output is energy sales information with the user's signature. The basic elements of chaincode are shown in Table 4. The Matchmaking Transaction Chaincode The inputs are demand information issued by BU and the sale information issued by SU. The chaincode matches the power unit with the power unit according to the trading strategy, completes the transaction authentication, and then forms a specific transaction path for each pair of matching buyers and sellers to generate transaction records. Then, all the information in the transaction path is encrypted with its private key to generate a random number, and then submits it to the fabric ledger for recording. The basic elements of chaincode are shown in Table 5. Transaction compensation chaincode includes supply and demand compensation chaincode and error compensation chain code. The inputs of supply and demand compensation chaincode are the demand and supply of electricity, transaction price, and grid's price. The chaincode calculates the supply and demand difference according to the submitted electricity sales and purchase information. When the amount of electricity sold submitted by the sellers is lower than the demand of buyers; that is, the difference is less than 0. The supply compensation chaincode is used to connect the grid to purchase electricity. Then the costs are borne by the buyers. When the difference is greater than or equal to 0, the chaincode is used to connect the grid, and the surplus power of the microgrid is sold to the grid. The basic elements of chaincode are shown in Table 6. The inputs of error compensation chaincode are the agreed transaction volume, actual transaction volume, transaction price, and grid's price. If sellers cannot provide the agreed transaction volume due to the forecast error, the chaincode calculates the difference, then purchases the power from the power grid and deliver it to the buyers. The costs are borne by the sellers. Finally, all the information in the transaction path is encrypted with its private key to generate a random number and then submits it to the Fabric ledger for recording. The basic elements of chaincode are shown in Table 7.

Case Study
In this section, the pricing strategy and trading model of microgrid market proposed in this paper were simulated and tested firstly. Through the deployment of chaincodes, a microgrid trading process is taken as an example to verify the feasibility of the trading model. Then, the transaction performances of the trading model were evaluated using Hyperledger Caliper. The experiment of the case was done on three computers. The consensus mechanism used in simulation experiment is Solo. The Go language was used to write the deployed chaincode [67].

Scene Settings
The simple microgrid market trading scenario was set up and then was simulated in a simplified Fabric network environment. The simplified transaction process is shown in Figure 3. Assuming that the DPGS in the microgrid is the PV system, the transaction period involved in the simulation experiment is limited to the period when the PV system has power output. Therefore, the basic data of 12 transaction periods from 7.00 to 18.00 are shown.
The PV output power refers to the calculation result of the PV output power of certain places on July 1. The microgrid consists of five users, each with a PV system and a smart meter. The parameters of PV systems and smart meter are the same, and the installed capacity of users is different. The initial power load and PV power of each user in the microgrid are shown in Tables 8 and 9, respectively. The price of "surplus power to the grid" for local PV users is 0.77 yuan, and price of power grid is 0.85 yuan.
The net PV power of each user participating in the microgrid transaction is shown in Table 10. It can be found that the PV output power of user 1 and user 2 is much larger than load, and their net PV power is greater than 0. Therefore, user 1 and user 2 are sellers. The PV output power of users 3, 4, and 5 is less than load, and the net PV is less than 0. Therefore, users 3, 4 and 5 are buyers. All sellers are divided into seller group, and all buyers are divided into buyer group. The power supply and demand of users are shown in Table 11. The sale of electricity in period 13 and 14 is larger than the demand. After the seller sells the electricity to buyers, the surplus power is sold to the power grid at the price of "surplus power to the grid". In other periods, electricity sales are less than demand, and therefore, after purchasing electricity in the microgrid, buyers need to purchase a certain amount of electricity from the grid to meet their demand. The simple microgrid market trading scenario was set up and then was simulated in a simplified Fabric network environment. The simplified transaction process is shown in Figure 3. Assuming that the DPGS in the microgrid is the PV system, the transaction period involved in the simulation experiment is limited to the period when the PV system has power output. Therefore, the basic data of 12 transaction periods from 7.00 to 18.00 are shown. The PV output power refers to the calculation result of the PV output power of certain places on July 1. The microgrid consists of five users, each with a PV system and a smart meter. The parameters

Simulation Results
The simulation results mainly include two parts. The first is the calculation result of the pricing strategy of the trading model. The second part is the performance test of transaction processing of the trading model. Through the analysis and discussion of the simulation results of these two parts, the microgrid market trading model was analyzed and evaluated.

Pricing Strategy Simulation Results
In this paper, the particle swarm optimization (PSO) algorithm was used to simulate and calculate the pricing strategy model, to find the optimal price of the microgrid market transactions and the optimal benefits of sellers.
The calculation results of the optimal electricity price for each period and the electricity load adjusted by sellers according to the electricity price and benefit are shown in Table 12. The trading power is shown in Table 13. It can be found from Table 12 that the electricity price in each period is between the price of "surplus power to grid" and grid price. In the period of large demand for electricity, the price of electricity increases correspondingly. In order to obtain more revenue, sellers adjust their power load correspondingly. The transaction volume of each user is shown in Table 13. The negative number represents the sales volume of sellers, and the positive number represents the purchasing power of buyers.
Therefore, the purchase cost of the trading model proposed in this paper and the cost of purchasing electricity from the grid are shown in Figure 4. The power sales benefit of the model and power sales benefit of "surplus power to grid" are shown in Figure 5. The results of electricity purchase cost show that the trading model proposed in this paper has lower electricity purchase cost than that of the power grid. The results of electricity sale benefit show that the electricity sale benefit obtained by way of "surplus power to grid" is much less than that obtained by the model proposed in this paper. In summary, the simulation results of the model show that the decentralized trading model of the microgrid saves the profit of the middlemen, increases the revenue of the seller, and reduces the electricity purchase cost of the buyer. In addition, the microgrid market trading model proposed in this paper can effectively solve the problem of the DG in-situ consumption, decrease power interaction, and thus reduce impact on the grid.

Performance Evaluation
The transaction capabilities of the proposed trading model were tested using Hyperledger Caliper. Hyperledger Caliper is a blockchain performance benchmarking framework. It allows users to test different blockchain solutions using predefined use cases and get a set of performance test results.
The transaction processing capability of a blockchain network is mainly reflected in two aspects: throughput and latency. Throughput is a critical reference index to measure a blockchain solution. This index is used to represent the number of transactions that blockchain network can handle in a certain period. Tps (transaction per second) is generally used to represent the number of transactions that can be processed per second. Latency refers to the time it takes for a blockchain system to process a transaction. In performance testing, the latency of requests refers to the time when a transaction moves from client to blockchain network and obtains the corresponding network. In general, ms (milliseconds) is used as the unit of this index.
Caliper sends transaction requests to the blockchain network through the preset http port, observing the trend of throughput and latency of the proposed model by continuously increasing send rate. The results are shown in Table 14.

Performance Evaluation
The transaction capabilities of the proposed trading model were tested using Hyperledger Caliper. Hyperledger Caliper is a blockchain performance benchmarking framework. It allows users to test different blockchain solutions using predefined use cases and get a set of performance test results.
The transaction processing capability of a blockchain network is mainly reflected in two aspects: throughput and latency. Throughput is a critical reference index to measure a blockchain solution. This index is used to represent the number of transactions that blockchain network can handle in a certain period. Tps (transaction per second) is generally used to represent the number of transactions that can be processed per second. Latency refers to the time it takes for a blockchain system to process a transaction. In performance testing, the latency of requests refers to the time when a transaction moves from client to blockchain network and obtains the corresponding network. In general, ms (milliseconds) is used as the unit of this index.
Throughput and average latency were analyzed, respectively. The case of average latency is shown in the form of a histogram in Figure 6. It can be seen in Figure 6 that with the increase of send rate, the average latency of the proposed model shows an overall upward trend. Before 280 tps, the growth of average latency was relatively flat, basically maintained at 1000 ms. When the sending rate exceeded 280 tps, it showed a sharp growth trend.
Throughput is shown in Figure 6 in the form of a broken line graph. With the increase of send rate, the overall throughput of the proposed model shows an upward trend, but when it reaches the saturation point of 280 tps, the throughput no longer grows, remaining in a stable state.
shown in the form of a histogram in Figure 6. It can be seen in Figure 6 that with the increase of send rate, the average latency of the proposed model shows an overall upward trend. Before 280 tps, the growth of average latency was relatively flat, basically maintained at 1000 ms. When the sending rate exceeded 280 tps, it showed a sharp growth trend.
Throughput is shown in Figure 6 in the form of a broken line graph. With the increase of send rate, the overall throughput of the proposed model shows an upward trend, but when it reaches the saturation point of 280 tps, the throughput no longer grows, remaining in a stable state. For evaluating the performance of the model based on the federated blockchain technology in this paper, the results of the proposed model with the bitcoin-based and the Ethereum -based trading model were compared. The comparison results are shown in Figure 7. As can be seen from the figure, regardless of the level of the send rate, the throughput of the trading model based on the consortium blockchain technology is significantly better than the other two blockchain trading models. For evaluating the performance of the model based on the federated blockchain technology in this paper, the results of the proposed model with the bitcoin-based and the Ethereum -based trading model were compared. The comparison results are shown in Figure 7. As can be seen from the figure, regardless of the level of the send rate, the throughput of the trading model based on the consortium blockchain technology is significantly better than the other two blockchain trading models.

Conclusion
In this study, the Nash equilibrium theory was combined with consortium blockchain technology to develop a trading model of a microgrid market and simulate the trading scenario. The analysis for results are as follows: (1) The pricing strategy based on Nash equilibrium theory can be used in power trading in the microgrid market. During a transaction cycle, the pricing strategy proposed in this paper can reduce the purchase cost of power consumers by about 5%, compared with the way of power

Conclusion
In this study, the Nash equilibrium theory was combined with consortium blockchain technology to develop a trading model of a microgrid market and simulate the trading scenario. The analysis for results are as follows: (1) The pricing strategy based on Nash equilibrium theory can be used in power trading in the microgrid market. During a transaction cycle, the pricing strategy proposed in this paper can reduce the purchase cost of power consumers by about 5%, compared with the way of power grid. For sellers, the power-selling benefit of using this pricing strategy is nearly double that of the use of "surplus power to grid". In addition, the price set by this model is higher than that of "surplus power to grid". Therefore, in order to obtain higher profits, sellers adjust their power load. (2) Conducting electricity transactions within the microgrid market can solve the problem of in-situ consumption of DG. The buyers first purchase the power in the microgrid. When the output power of the DG in the microgrid is insufficient, the buyers purchase the power shortage from the grid. This method can reduce the power interaction between the microgrid and the grid, thereby reducing the impact of the microgrid on the grid. (3) The transaction processing capability of blockchain technology is mainly reflected in two aspects: Throughput and Latency. The trading model based on consortium blockchain technology proposed in this paper is superior to Bitcoin and Ethereum in terms of Throughput and Latency evaluation. In other words, compared to Bitcoin and Ethereum, the microgrid market trading model using consortium blockchain technology has dramatically improved the speed and ability of processing transactions.
However, the simulation scenario set in this paper is relatively simple, and the transaction volume is small. Therefore, whether this model can perform well in the actual application scenario needs further verification.