Centralized Blockchain-Based Energy Trading Platform for Interconnected Microgrids

Inter-connected Microgrids (IMGs) have emerged as a promising structure for future grids, offering resilience and independence in energy exchangeability with neighbours. To enable such interconnected structure, an interconnected market between individual Microgrids (MGs) participating via an agent (i.e., Energy Management System [EMS]) is required. Each agent is Self-Benefit-Driven (SBD), which means that it works in the best interests of its own MG. Therefore, energy trading is established to enhance these benefits. In this paper, a new strategy is proposed for IMG energy trading that considers SBD actions for MGs’ agents, and a unique utility function for each MG is defined. The function includes import and/or export benefits for each MG. Furthermore, the definition of the utility also considers the MG’s different objectives when importing versus exporting. A centralized Nash bargaining model is proposed for IMG energy trading to ensure fair settlements through a central entity (e.g., Distributed System Operator [DSO]). The proposed algorithm is developed using an adapted blockchain that enhances the security and transparency of the platform. The effectiveness of the proposed strategy is verified using a number of case studies.

Energy management and trading between interconnected microgrids (IMGs) has been gaining increased attention of late. The goal of establishing an interconnected market between individual microgrids is to provide sustainable, clean, and affordable energy to local participants, including residential, commercial, and industrial customers. The concept of IMGs was introduced in [1], with the authors proposing a multi-agent structure with distributed decision-making that offers a plug-and-play system. A related study showed that adjacent microgrids (MGs) could provide complementary generation from their renewable resources [2], thus maintaining the sustainable operation of MGs.
Another factor that promotes the concept of IMGs is the increased penetration of Distributed Energy Resources (DERs). This new paradigm allows each MG to supply the local load from the cheaper energy sources, thereby creating competition between different sources. DERs play a major role in this paradigm, as their energy is mostly renewable and unburdened by the traffic cost (i.e., transmission charge). Moreover, the high penetration of renewable generation units will reduce energy loss and improve the performance of MGs [3]- [5].
Energy management strategies for IMGs can be categorized into two main schemes: centralized and decentralized. In centralized management, information flows from each MG to a central decision-maker (e.g., Distributed System Operator [DSO]) [6]- [9]. The DSO then distributes settlements and commitments to the MGs. In the decentralized scheme, decisions are made in a distributed manner [10]- [14], with MGs communicating only with their neighbours to reach an agreement. The first centralized has the advantage of having full knowledge of the system data, so a predefined global objective could be optimized efficiently. On the other hand, the decentralized scheme has the advantage of protecting the privacy of the participating MGs and enhancing reliability. The main differences between the centralized and decentralized energy management in IMGs are summarized as shown in Figure 1 [15]- [17].

II. LITERATURE REVIEW AND RELATED WORK
Considerable research work has been conducted to propose and enable energy management for IMGs using various algorithms and techniques. In [18], the authors proposed an approach utilizing a game-theoretic algorithm to incentivize participants for fair energy trading. This algorithm is designed for MGs dominated by renewable energy resources. The proposed model adopted the discomfort cost for each participant as its utility function in the game.
In [19], [20], another approach based on fair energy trading using priority factors and aggregators for buyers and sellers was introduced. This algorithm used a utility function for sellers and buyers that inherits their priority factors while the settlement is achieved via solving a Nash bargaining game. The limitation of this algorithm is its use of unified aggregators for sellers and buyers, regardless of their hosting MGs. In this approach, no preferences can be imposed by individual MGs. Moreover, the utility function used for buyers is independent of the energy price, which is a main factor for energy trading from a buyer's perspective.
The aforementioned work did not consider uncertainties in renewable sources and load variations. In [21], the authors considered uncertainties in IMG energy management using a bi-level day-ahead market, while in [22], a real-time IMG market that weighs uncertainties using modified robust optimization technique was discussed.
Alternating direction method of multipliers (ADMM) has been widely employed to break the overall optimization problem into distributed problems. This method is well-suited for IMGs, as solving sub-problems at each MG offers better convergence. The authors in [23] presented a closed-form solution for ADMM that significantly improved the computational time of optimizing the energy trading. In [24], the authors proposed a framework for online energy management without the need to forecast data using the ADMM method. Moreover, in order to obtain a robust and optimal energy management plan for the IMGs, a distributed adjustable robust optimal scheduling algorithm (DAROSA) was proposed in [25]. The solution represents a compromise between robustness and optimality.
Researchers have also studied the greedy manners of energy management. In [26], a novel collaborative transactive energy algorithm is developed, with the algorithm incorporating the physical constraints of the network. However, this method does not satisfy the expected SBD behaviour of the MGs. Other researchers are suggesting a Peer-to-Peer (P2P) approach to handle energy trading in MGs, such as the P2P energy trading mechanism proposed in [27]. Although the algorithm shows proper response time for P2P negotiations, its implementation to the blockchain is ambiguous. Furthermore, the model behavior in real-time mismatches is still questionable, as the imbalance settlement in the P2P approach is challenging and needs to be addressed [27].
In [28], a decentralized P2P market is developed that considers the preferences of DSOs, prosumers, and generators. In this approach, the grid is assumed to account for all system losses, which may not be a feasible scenario, as the grid's interest in providing this service is not justified. Although the blockchain is considered a promising solution for P2P trading schemes [29]- [31], blockchains need adaptation in order to be integrated seamlessly within the existing market structure.

III. CONTRIBUTION
As discussed above, previous related research in the literature proposed a centralized IMG energy management framework. However, none of the proposed techniques provided either a SBD strategy for participating MGs or a secure monetary fund. While the authors in one work did present the concept of Peer-to-System-to-Peer (P2S2P) as a unique solution to enable energy trading using an adapted blockchain structure, the work was limited to introducing the blockchain adaptation and integration rather than the negotiations and market settlements in IMGs with different preferences [32].
This paper presents a novel trading framework for IMGs that considers a SBD strategy for MG interactions within the market. By considering the MGs' actions to be selfish, this paper provides a comprehensive mathematical model for centralized energy trading that assumes different operating strategies. In addition, a blockchain integration with the proposed market structure is developed in order to facilitate monetary fund handling for the IMGs.
The proposed integrated framework offers a fast, simple, and efficient trading mechanism for IMGs that also considers the individual preferences of the participating MGs. The framework allows each microgird to import or export or maximize its own benefits. The main contributions of this paper can be summarized as follows: • Propose an energy trading structure that connects inter-transactions between MGs and intra-transactions within MGs. This framework takes into consideration both the internal bidding for the consumers and prosumers and the microgrid-to-microgrid transactions.
• Establish a self-benefit-driven cooperative energy trading framework by: 1) Defining a new self-benefit utility function for each MG to export/import energy to/from an interconnected market assuming SBD behaviour. 2) Developing a centralized energy trading platform using Nash bargaining and implementing a UMP market model to ensure market uptake.
• Adapt the blockchain layer to interconnect the MGs' internal chains and store the MGs' transactions. The proposed blockchain adaptation provides a secure, transparent, and efficient monetary fund.
The rest of this paper is organized as follows. Section III discusses the centralized energy trading structure. Section IV introduces the energy trading platform. Section V presents the mathematical model for the proposed energy trading algorithm. Relevant case studies are proposed in section VI. Monetary fund verification is provided in section VII, and section VIII draws the conclusion.

IV. CENTRALIZED ENERGY TRADING STRUCTURE
In this paper, energy trading is enabled between IMGs by utilizing a centralized IMG structure. Although all of the MGs participating in the energy trading platform seek equilibrium benefits, they will be selfish players and therefore will first solve their market internally in order to maximize their own internal social welfare. Afterwards, they can trade with others seeking extra benefits, where feasible. Therefore, in this structure, each MG has its own Energy Management System (EMS) that runs an energy trading engine (as proposed in the present authors' previous work [32]), which determines their internal MCP. They then participate in the IMG energy trading platform to gain more benefits by either exporting surplus energy or importing cheap energy. It is worth noting that the utility (i.e. grid) can participate in the proposed model and submit bidding to sell/purchase energy from participating MGs. Therefore, the proposed algorithm can be used for islanded and grid-connected modes.
The DSO is assumed to be the entity handling the energy trading settlement among the IMGs. Therefore, the DSO runs the central market model to provide a fair solution for all participants and determine exporters and importers.
As shown in Fig. 2, the DSO receives information from the EMS of each MG. This information is: 1) Aggregated bidding from MGs for their generators and loads for each MG that has decided to participate in the trading (i.e., the curves are in the form of price/energy pairs). 2) Internal social welfare.  3) Excess available generation that is available after satisfying internal demands. The DSO runs the proposed energy trading model to settle the transactions between the MGs. It should be noted that the proposed structure interconnects all of the MGs' blockchains to store the IMGs' transactions, as will be discussed later.
It should be emphasized that the main focus of this paper is developing a framework for energy trading between interconnected microgrids'. If an MG is disconnected from the system, it will not be able to send bidding to the central unit and will be exempted from the interconnected market solution.

V. CENTRALIZED PLATFORM BASED ON NASH BARGAINING
This section describes the Nash solution, algorithms, and assumptions for the proposed energy trading framework in IMGs. As mentioned earlier, a centralized solution will be determined by the DSO. This centralized solution is developed based on a Nash bargaining formulation for trading between IMGs. The formulation aims to find a mutual solution that satisfies all participants. Note that the utility functions are uniquely developed from the basic principle of the UMP model to reflect the SBD behaviour assumed in this research. The developed Nash bargaining model and its monetary fund with the proposed platform is discussed in the next subsections.

A. MG UTILITY DEFINITION
In this subsection, the utility function for each participating MG is formulated. Assuming a cooperative game, each MG will act to maximize its own benefits defined by its utility function. The utility function used for a single MG aligns with the SBD concept. In this regard, each MG can export/import energy to/from the IMG market in order to increase its social welfare or at least secure energy at prices cheaper than its internal MCP.
Given the demand and surplus generation in each MG, the proposed algorithm defines two utility functions (i.e., import and export) to describe its trading mode. Importing MGs will seek lower energy prices for their own load or higher demand coverage at the same MCP, if any, offered by neighboring MGs. On the other hand, exporting MGs aim to maximize their generators' benefits by exporting surplus energy to neighbours without affecting the energy prices offered to their local loads. These are the logic rules that we considered in our energy trading framework. Importers act to supply more demand at lower prices, while exporters try to trade surplus energy and keep their local load prices unchanged. Figure 3 shows general offer/bidding curves for a generator/load, which are used to find the market clearing price. In this scenario, λ 1 represents the marginal price in the case of isolated operation that maximizes internal social welfare, denoted by the area between the two curves shown in Fig. 3. In the case of importing cheaper energy from neighbours, an MG will have a modified generator offer curve and thus gain additional social welfare (i.e., import area A I and price [λ 2 : marginal price in the case of importing]). As indicated by the figure, energy import will lower the price and/or increase the demand covered within the importing MG.
On the other hand, in the case of exporting, an MG can offer its excess generation (i.e., after clearing the local market) in the IMG market. In this way, MGs can gain additional social welfare for generators (i.e., export area A E ) without changing the local market price (λ 1 ) after achieving a new export price (λ 3 : marginal price in case of exporting). This price (λ 3 ) represents the price in the receiving MG, not the exporting MG, and is lower than its MCP, as explained earlier.
The following assumptions are used in the proposed trading framework: • Each MG is assigned only one mode of operation: either to export or to import through the same link at a given time.
• MGs can be connected in series, parallel, or mesh.
• End-users and prosumers can submit their aggregated bidding and participate in their local market.

B. CENTRALIZED NASH EQUILIBRIUM SOLUTION
In this paper, a centralized Nash equilibrium for cooperative strategic energy trading game is proposed. The DSO is assumed to be the entity handling this process by solving the Nash bargaining problem and identifying the Nash equilibrium for all participants. This technique provides a fair solution for all participants and can easily determine exporters and importers. The Nash objective is to maximize the utility difference between agreement (u) and disagreement (d). In our model, the disagreement part is set to zero. As mentioned earlier, MGs participate to enhance their gains via trading, so if the trading is not improving their gains, no trading is better. Thus, it is logical to assume a disagreement cost of zero: subject to: Equation (1) defines the objective of the proposed model as the sum of import and export areas, while Eq. (2) represents the minimum acceptable trading benefit to participate in the game. Equation (3) ensures that an MG (i) cannot import and export at the same time through the same link (k).

C. CENTRALIZED PLATFORM MONETARY FUND
Blockchain technology is used in the proposed framework to promote the independent operation of participating MGs and to utilize the numerous benefits blockchains offer. In [32], the authors presented a blockchain structure that can work as a monetary fund for individual grids and handle the intra-gird transactions. However, this blockchain has to be interconnected with other chains in order to enable trading in the case of an interconnected market. This entails further adaptations for the blockchain to make it capable of handling inter-grid transactions. Figure 4 shows a general overview of the proposed structure to enable inter-grid transactions. The proposed blockchain mimics the physical layer of the power system while establishing transactions, thus mirroring the financial cash flow and the actual power flow. The proposed blockchain structure assumes coupled chains, a Microgrid Chain (MC), and an Inter-Grid Chain (IGC).
The MCs are connected to the IGC to handle intergrid transactions while keeping the operation transparent for all MGs. The Two-Layer Structural Chains (TLSC) have the following chains: 1) MCs that act as a monetary fund for intra-grid trading transactions between loads and generations, as shown in Fig. 5; and 2) IGCs that are connected to all MCs with access to the MGs' global wallets.
It is worth mentioning that the IGC blocks store all transactions among participating MGs that have been settled by the centralized market algorithm proposed in section 4.4. In order to ensure the security of all participating MGs and enhance the trust in the proposed framework, a unique hashing algorithm is used for the proposed TSLC model. As shown in Figure 6, each MG block records the previous hash that inherently contains the data of the previous block as well as that of the previous IGC block. Furthermore, each IGC block records the hash of the previous IGC block. This provides a very sophisticated security level that stores and encrypts all the data (i.e., internal data and interconnected data) in both chains. As a result, the proposed TLSC makes the system immune against any manipulation from participants. At the same time, all the IMG transactions are stored locally at each chain to ensure transparency for all participants.
Two consensus algorithms are used in the proposed TLSC structure. One is the Proof of Work (PoW) consensus, which is used for mining blocks inside each MG, employing the same concept proposed in [32]. The other algorithm is the Proof of Authority (PoA) consensus (i.e., Proof of Identity), which is used by the DSO to mine the IGS's blocks. This separation ensures independent operation for MGs, with each VOLUME 9, 2021  The timing diagram shown in Fig. 7 represents the operation for one day. The sensitivity analysis is performed on a slot-ahead basis to accommodate for the losses in individual MGs. Each MG mines bundled blocks using the PoW consensus algorithm. These blocks contain internal market data as well as real-time data received from smart meters. Moreover, the DSO receives the data from the MGs after solving their internal market and uses these data to solve the proposed centralized Nash problem in order to settle the transactions between the MGs. Afterwards, the internal transactions are updated and mined in each MC as MCB, as shown in Fig. 7. Thereafter, the market commitment transactions between MGs are mined by the DSO using the POA concept of onetime at the final time slot in the day. Real transactions between IMGs are mined and stored at the very first slot of the next day, as illustrated in Fig. 7.
As shown in Fig. 7, the interconnection between the local energy trading engine proposed in [32] and the centralized trading framework presented in this paper could be summarized to the following steps: • Each MG solves the market internally to calculate the local price, social welfare, and the available generation.
• This data is communicated to the central operator to solve the interconnected market, find the intra-transactions and communicate them to the participating MGs.
• Each importer MG applies the trading check to ensure that the MG gains benefits from the received offers.
To pass this condition, the demand covered should increase and/or the internal price should be reduced when including these offers. If the received offers fail to satisfy these conditions, they should be rejected, and their transactions are eliminated from the platform to ensure that the model follows the SBD for each MG. It is worth noting that this trading check is to solve the double auction market considering the offers received from other MGs. Thus the internal price and demand could be determined.
• Based on the trading check, each MG writes down in its MG chain the commitments.
• All inter-transactions commitments are stored once per day in the inter-grids chain, connecting all the MGs' chains.

VI. CENTRALIZED PLATFORM OPTIMIZATION MODEL
This section explains the mathematical formulation of the proposed energy trading frameworks. As mentioned earlier, two different utility functions are defined for each MG. In the case of importing, the utility function is to maximize the Effective Social Welfare (ESW), as defined by Eq. (4). On the other hand, the utility function in the case of exporting is intended to maximize the Export Benefit (EB), as defined by Eq. (5).
The first term in Eq. (4) represents the gross surplus of the customers, and the second term represents the total cost for internal generator units. It is worth mentioning that the no-load cost of the generators is included in the first block submitted by each generator. The third term represents the total cost of generators in the connected MGs that have excess energy and can export. The mathematical model is subjected to the following constraints:  The first term represents the internal demand of MG i , and the second term represents the internal generation, while the third term represents the imported energy from all neighbouring MGs.
• Clearing constraints: These constraints ensure that the cleared demand and generation for each MG do not exceed their upper limits according to the bidding blocks.
The cleared exported energy from each MG does not exceed its upper limits assigned by the EMS of each MG.
The cleared exported energy is defined as the sum of all exported energy to its neighbouring MGs, The exported energy is set to zero if the block's price exceeds the imported MG internal price • Social welfare improvement constraint: This constraint reflects the greedy participation (SBD) of MGs, as mentioned earlier. Each MG participates in the interconnected market only if this will improve its own benefit, regardless of others. Specifically, the demand of each MG should not get a higher price or receive less energy at the same price after participating in the market. As the demand bidding curve of each MG is known, the price will be reduced or the demand covered will be increased if the social welfare of the MG after trading is greater than the social welfare calculated before trading.
• Physical flow constraint: This constraint ensures that each MG can either export or import on the same connection at a given time.
• Trading conditions check: Each importer MG applies this trading check by solving a double auction market in order to ensure that the MG is gaining benefits from these offers. In order to pass this condition, the demand covered should increase, as in Eq. (14), or the internal price should be less, as in Eq. (15). If the MG fails in these conditions, it should be eliminated from the platform to ensure that the model follows the SBD for each MG. This condition will allow each importer MG to calculate the new internal price after trading.

VII. CASE STUDIES
The proposed energy trading platform was implemented and tested assuming four MGs with different generators and demand biddings. Each MG is assumed to have the layout of the IEEE 906 European low voltage test system with 55 loads and four generators. Further, the proposed framework is assumed to be solved on an hourly basis. Table 1 shows the solution for the UMP model inside each MG. The model assumes no trading in order to highlight the differences between these MGs and to be a benchmark for comparisons and discussions. The table presents their internal uniform price, social welfare, and total demand covered at this price. The generator and load biddings for each MG are given as three different blocks of price/power pairs (i.e., B1, B2, and B3), as shown in Appendix. For simplicity, assuming identical connection between MGs, the loss factor (ζ i ) is determined to be 0.00289.

A. IEEE 906 BUS UMP-BASED BENCHMARK CASE STUDY
The classic UMP model was employed in this study as a benchmark for energy trading among the IMGs. The model is solved for the four IMGs mentioned earlier. Table 2 illustrated the output from the UMP model. It should be noted that this model is still in usage by the IESO. It is clear from Table 2 that this model offers a unified internal price for all participating MGs. Also, it can be seen that the power is exported from the low-priced MGs (i.e., MG-T1 and MG-T2) To the high priced ones. This model is used as a benchmark because it can provide a fast and reliable solution while adopting the large number of participants.

B. IEEE 906 BUS CENTRALIZED NASH-BASED CASE STUDY
The Nash bargaining model was applied to two different scenarios. For the first scenario, all MGs are assumed to be interconnected using one link (mesh connection). Therefore, each MG can exchange energy with the other three MGs. In the second scenario, the interconnection link between MG-T2 and MG-T1 and the link between MG-T2 and MG-T4 were removed. This assumption is used to show that the proposed approach will find the proper solution for any interconnection topology and to highlight the effect of inter-connectivity on the market solution and energy trading.
The mathematical model used to solve the centralized problem is formulated as follows: max i∈NŜ WE i +Ê B i subject to : (6) − (13) Note that N = 4 in both scenarios, whereas the connections between MGs are different. Figure 8 shows the results obtained from solving the centralized Nash bargaining algorithm. As can be seen, MG-T1 and MG-T2 are chosen by the algorithm to export power, as they have a low internal uniform price. For MG-T1, the Nash solution selected generators (G1, G3, and G4) to export energy. In order to benefit all participants, low-priced generators exported to MG-T3 and high-priced energy is exported to MG-T4, which has the highest internal energy price. For MG-T2, generators G1, G2, and G3 were selected to export. As expected, Block#3 for all generators was not selected to export, as the price of these blocks is higher than the internal prices of the importing MGs. Specifically, the exported energy from MG-T1 is 299.388 kWh, and the imported energy is 105.116 kWh, as shown in Table.3.

1) FIRST SCENARIO: FIRST TOPOLOGY
It is clear that the trading held the internal price of MG-T1 constant while increasing the export benefits and the demand covered. Furthermore, the algorithm was able to determine for each link whether to export or import in such a way as to maximize each MG's benefits while being fair to all participating MGs.
On the other hand, the utility function used to represent each MG in the Nash bargaining is selected assuming an SDB from the MG. In addition, the MG cannot export and import on the same link at the same time, but can do so via different links. For MG-T2, the algorithm selected to export  218.962 kWh to neighbours. Therefore, the export benefits for MG-T2 increased while the SWE remained unchanged.
Furthermore, the total exported energy from MG-T1 is higher than MG-T2, as is the normalized utility. The reason for this can be found in the amount of available energy for export from MG-T2. The results show that the total demand covered in MG-T3 increased to 208 kWh, while the price dropped to 10.2 ct/kWh. Although the price remained constant for MG-T4, the total demand covered increased by almost 200%, as presented in Table 3. The normalized utility values for the MGs prove that the Nash solution tried to be fair to all the MGs by improving their normalized utility functions correspondingly.
As it is not logical to have energy trading between MGs if there is no direct connection, trading is only possible between two MGs with a direct connection. However, one MG can buy cheaper energy from another MG and then sell it to other MGs, as shown in the results provided for the first scenario presented in Table 3. MG-T1 was able to buy cheap energy from MG-T2 and sell it to MG-T3 and MG-T4.

2) SECOND SCENARIO: SECOND TOPOLOGY
In the second scenario, the link connecting MG-T2 to MG-T4 is removed and thus no energy can be traded between them; the same holds for MG-T2 and MG-T1. However, the Nash solution maximized MG-T2's benefits by increasing its exports to MG-T3 by 120% compared with the first scenario, as shown in Fig. 8 and Fig. 9. As presented in Table 4, the settlement price of MG-T3 remained the same in both scenarios, while the total energy imported increased. Although no energy was exported from MG-T2 to MG-T4,   the normalized utility for MG-T4 is nearly constant compared with the first scenario. Thus, from this we can see that the centralized Nash method is adapting the solution for any changes in the MGs' connectivity. Therefore, this approach can be used for any topology and is not limited to meshed-or parallel-connected MGs. Table 5 presents a comparison between Scenerio#1 and Sce-nario#2. Because the interconnection between MG-T1 and MG-T2 was removed, the imported energy from MG-T2 dropped to 0 compared to 105.116 kW in the first scenario. Therefore, the effective social welfare fell to $19.31 compared to $23.24. This drop for MG-T1 is compensated by increasing the exported energy by 38%. Specifically, the increase leveraged the export revenue for the MG-T1 to $32.5 compared to $30.54 in the first scenario.  It is worth mentioning that the exported energy for MG-T2 remained the same. Although the link between MG-T2 and MG-T1 was removed, the proposed algorithm succeeded in finding an alternative for the participating MG to export more energy to MG-T3. The imported energy for MG-T3 and MG-T4 also remained the same, but the internal price for MG-T4 dropped to $/kWh 0.077. The reason for this change is that MG-T4 succeeded in receiving cheaper energy from MG-T4. This energy was then exported to MG-T1 in the first scenario, as there was a link between the two MGs.

C. CENTRALIZED NASH SOLUTION VS BENCHMARK SOLUTION
The solution obtained from the proposed centralized Nash is compared with the UMP benchmark presented earlier in Table 6. It can be noted that the low-priced MGs received higher internal prices, as highlighted in yellow, giving these MGs no incentive to participate in the market following the UMP model. In addition, the internal demand covered for the low-priced MGs is less when the market followed the UMP model. On the other hand, the high-priced MGs received better internal prices, which provides an incentive for them to participate in the trading at this time. This scenario may not, however, be the case in another time slot. Therefore the UMP model is a hypothetical model that may not offer a feasible solution that incentive participants and thus will not satisfy the SBD participants.

VIII. MONETARY FUND VERIFICATION
In order to verify the integration of the proposed Nash solution and the adapted blockchain, the proposed blockchain was coded using Python. The coded blockchain succeeded in integrating with the internal blockchain of all the MGs and to record the transaction between them. A sample of the transactions recorded in the blockchain is shown in Fig. 10. The transaction was 70 kW priced at 0.102 $/kW between MG-T1 and MG-T4. As illustrated, the coded blockchain recorded the public key of the sender MG (i.e., MG-T1) and the recipient one (i.e., MG-T4). Additionally, the power calculated from the Nash solution is recorded with the corresponding price (i.e., amount), and the new fund of the recipient and sender is calculated assuming that the recipient has consumed all the power in real time. It is worth noting that only the fund of the recipient is shown in the transaction to match the transaction's size of the internal transactions stored in the MCs.

IX. CONCLUSION
This paper proposed a platform for energy trading between IMGs utilizing adapted blockchain technology and a centralized Nash bargaining algorithm to settle the IMG market. The proposed platform was developed to satisfy the MGs' SBD behaviour while allowing them to participate in a fairly settled market. The platform can be used for any microgrid topology and was tested for two different scenarios. Microgrids were allowed to export and import to maximize their benefits, with the Nash bargaining algorithm ensuring fair social welfare distribution among participating MGs.
The case studies showed the effectiveness of the proposed platform in handling the IMG market. It can be seen from the presented results that the participating MGs gained benefits from participating in the trading. Both the normalized utility and the normalized benefits of all the MGs were improved. A novel definition for import and export utility functions was introduced to reflect the rational behaviour of MGs. Moreover, the platform presented a swift integration of each MG's transactions and inter-grid transactions through a TLSC.
Finally, a secure and transparent blockchain structure was proposed in this work by using two consensus algorithms, namely POW for MC and POA for IGC. The platform was developed and tested by integrating several software packages (MATLAB, GAMS, and Python). The IMGs' transactions were stored in the blockchain and verified via sample transactions.

APPENDIX GENERATOR BIDDING DATA
The parameters utilized in the case studies for the generators' bidding limits are shown in TABLE 7.