A Blockchain-Based Scalability Solution with Microgrids Peer-to-Peer Trade

: In recent years, advancements in rooftop solar panel technology have sparked a revolution in the electricity markets. This has given rise to a new concept of energy exchange—the ability for consumers and producers to trade localized energy. This concept has been made possible by the emergence of blockchain technology, which has gained significant traction in the energy markets. Its unique ability to facilitate peer-to-peer (P2P) energy transactions has made it a promising solution for the trilemma of scalability, security, and decentralization. However, while blockchain technology has shown great potential, it is still in its early stages of development and has yet to reach its full potential. To fully understand the potential of blockchain technology in P2P energy trading, it is important to explore the trilemma in depth. This study proposes a blockchain-based scalability solution with a focus on P2P energy trading. This strategy is supported by empirical modeling, utilizing data gathered from a trial case study. The results of this study demonstrate that the suggested technique outperforms base-layer models in terms of scalability while still maintaining the essential elements of security and decentralization. This proposed solution not only has the potential to revolutionize the energy markets but also has broader implications. By providing a more secure and decentralized platform for P2P energy trading, it has the potential to address issues of energy distribution inequality and promote the adoption of renewable energy. With blockchain technology, individuals and communities have the opportunity to take control of their energy usage and production, reducing their reliance on traditional centralized energy systems. This not only has the potential to lower energy costs for consumers but also contributes to the overall goal of reducing carbon emissions and mitigating the effects of climate change. The combination of rooftop solar panel technology and blockchain applications has the potential to create a significant shift toward decentralized and sustainable energy systems. This will not only benefit individuals and communities but also have a positive impact on the environment and the global energy market. However, for this transition to occur, it is crucial that governments and energy companies continue to support and invest in these advancements.


Introduction
Over the past decade, Distributed Energy Resources (DER) have experienced a substantial global proliferation [1][2][3][4].These resources have revolutionized the dynamics of energy generation and distribution within the energy sector by enabling consumers and prosumers (individuals who both generate and consume electricity) to engage in direct energy sharing without the necessity of intermediaries.This paradigm shift is exemplified by peer-to-peer (P2P) energy systems, which facilitate surplus energy exchange among prosumers and other network participants, including consumers and prosumers.
Trading electricity in a P2P manner caters to the requirements of both consumers and prosumers while simultaneously reducing transmission losses.Nonetheless, the inherent fluctuations in the supply and demand of energy might introduce instability, potentially impacting its reliability.The "energy trilemma" encapsulates the central challenges that confront the energy industry, characterized by the conflicting imperatives of energy security, equity, and environmental sustainability.
DERs present localized energy solutions, which are different compared to standard unidirectional energy systems.In the traditional model, power is generated at centralized power stations, distributed through expansive distribution networks, and subsequently transmitted to consumers.Conversely, DERs facilitate energy exchange within a P2P network, classifying end-users into consumers and prosumers, both of whom can engage in reciprocal energy sharing, referred to as energy trading.
A cutting-edge use of blockchain technology that is profoundly altering the energy area is peer-to-peer energy trading.This innovative approach enables prosumers-individuals who produce and consume electricity-to sell their surplus energy to nearby customers directly by bypassing conventional middlemen like utility corporations.The way we generate and use power might be revolutionized by this move toward decentralized, transparent, and secure energy markets.Prosumers who use renewable energy sources (RES) to produce their electricity, such as solar panels, have the chance to sell any surplus to other customers through P2P energy trading.In making these transactions possible, the blockchain becomes essential because it offers a safe and transparent platform for tracking each trade of energy.These transactions are smooth and automatic because smart contracts are self-executing agreements with established rules.The advantages of this approach are manifold.Firstly, it empowers prosumers, allowing them to monetize their surplus energy at a fair market price.This incentive encourages further investments in renewable energy sources, contributing to a more sustainable energy ecosystem.
Furthermore, the blockchain's role in streamlining transactions leads to reduced costs, making P2P trading economically viable.It also ensures the security and transparency of transactions, reducing the risk of fraud and enhancing trust among participants.The decentralization inherent in P2P energy trading reduces the dependence on central utilities, thus promoting a more distributed and resilient energy grid.As P2P energy trading gains momentum, several startups, including LO3 Energy (LO3 Energy-Start Up Energy Transition (https://www.startup-energy-transition.com,accessed on 18 November 2022)), have pioneered platforms for these transactions.Established utilities are also exploring blockchain-based solutions.P2P energy trading has the ability to transform the energy landscape, making it more sustainable, effective, and available to all.Renewable energy sources are being adopted at an increasing rate.Blockchain stands at the forefront of this energy revolution, offering a secure and transparent foundation for transactions that benefit both producers and consumers alike.
Businesses are starting to acknowledge the extensive application of blockchain technology in P2P energy trades, which is prompting them to change their business strategy.The blockchain revolution is fostering innovation and steering the energy sector toward more intelligent grids.Nevertheless, the realization of blockchain's full potential in P2P energy trading is an ongoing journey, marked by proof-of-concept and adoption phases.Existing limitations related to blockchain performance, scalability, and interoperability continue to be subjects of discussion.Implementing blockchains at a large scale remains a challenge, with the lack of communication and interoperability between different blockchain networks hindering scalability.
This research paper is guided by three key objectives, which include looking into P2P energy trades and evaluating how the blockchain plays a part, suggesting a flexible, reliable, and safe framework that facilitates efficient and frequent energy exchange; finally, assessing the feasibility of the suggested model by conducting a practical test of peer-to-peer energy trading as a real-life example.The parts that follow will provide a thorough analysis of the literature, examine multiple energy trading models that utilize blockchain technology for peer-to-peer transactions, present a case study, and address potential future research areas.The terminologies utilized in this paper are outlined in Table 1.
Table 1.Terminologies used in the paper [3][4][5][6][7].P2P energy trading has gained attention in academia and industry.Researchers like [7] categorize P2P systems into building, storage, and renewable domains, exploring network features and market dynamics.They classify P2P energy trading systematically, addressing virtual and physical layer challenges.Similarly, Ref. [8] highlights blockchain's integration benefits in smart energy systems, emphasizing the required technologies.We explore blockchain's use cases in energy trading, analyzing its relevance and potential advantages in this sector.Ref. [9] offers criteria to decide when blockchain surpasses traditional databases.When it comes to peer-to-peer (P2P) power trading, blockchain eliminates intermediaries in favor of decentralized miners that verify transactions and maintain the trade ledger.Blockchain technology helps P2P energy trading tremendously by enabling a successful renewable electricity market on a digital P2P platform.This approach enhances energy security, promotes sustainability, and supports low-carbon solutions.The on-chain issue in blockchain has been a topic of discussion in literature for several years.Ref. [10] highlights the challenges that arise when trying to scale blockchain technology.They argue that the current block size limit in most blockchain networks is a major barrier to scalability, as it limits the number of transactions that can be processed in a given time.This ultimately leads to slower transaction processing times and higher transaction fees.Similarly, Ref. [11] also identifies the on-chain issue as a major obstacle to the widespread adoption of blockchain technology.They note that the current transaction processing speed of most blockchain networks is significantly lower than traditional payment systems, such as Visa and Mastercard.This makes it difficult for blockchain to compete in industries where fast transaction processing times are crucial, such as finance and supply chain management.Various solutions have been proposed in the literature to address the onchain issue.One approach is to increase the block size limit, as proposed by [10].This would allow for more transactions to be processed in each block, thereby increasing the overall transaction processing speed.However, this solution has its limitations, as it could lead to centralization of the network and compromise its security.Another proposed solution is the implementation of off-chain scaling solutions, such as the Lightning Network.In [12], the authors describe how the Lightning Network can be used to enable fast and cheap transactions off-chain while still leveraging the security of the underlying blockchain.This solution has gained significant traction in recent years, with many blockchain networks, including Bitcoin and Ethereum, implementing or planning to implement off-chain scaling solutions.Additionally, researchers have explored the use of sharding as a solution to the on-chain issue.Sharding involves dividing the blockchain network into smaller subsets, or shards, and processing transactions in parallel.This would increase the overall throughput of the network and allow for more transactions to be processed simultaneously.However, this approach is still in its early stages and requires further research and development before it can be implemented effectively.

Terminology Meaning
Peer-to-peer (P2P), business-to-business (B2B), energy markets, commodities trading, and nonprofit endeavors are just a few of the applications being investigated by established organizations and pilot projects throughout the world for blockchain integration in the energy sector [6].A notable blockchain use case that promotes the expansion of renewable energy and the shared economy is peer-to-peer energy trading.Though relatively new, companies in this field signify blockchain's early development.The lack of concrete proof of its performance in the P2P energy trade has sparked ongoing arguments about its prospects and problems, particularly in the context of the blockchain trilemma.However, as described in [12], energy trading (P2P) and the application of blockchain in it presents several technological difficulties.Strong protocols and algorithms are required for network administration to oversee blockchain activities.On-chain and off-chain data [13] handling is both a part of data management.The resolution of consensus management's throughput and latency problems is essential for transaction validation.Power loss management addresses fluctuations in distribution and consumption.Dynamic pricing models offer avenues for further exploration tailored to P2P energy trading dynamics.Innovative prosumer business models and the promotion of renewable energy communities for energy transition are facilitated through a P2P strategy proposed by [5], which integrates demand and production forecasting.However, our approach stands out as it does incorporate the blockchain-based scalability layer.This involves creating a second layer on top of the main blockchain network, which can handle a higher volume of transactions at a lower cost.The scalability layer is built on top of the main blockchain network and acts as a sidechain.It can handle a higher volume of transactions by processing them off-chain, meaning they are not recorded on the main blockchain but are still secured by it.This improves the speed and efficiency of transactions while reducing the cost.One of the key advantages of this approach is its ability to enable micro-transactions.With the scalability layer, smaller transactions can be processed without clogging up the main blockchain network.This is particularly beneficial for industries such as gaming and content creation, where microtransactions are common.Moreover, the scalability layer also allows for faster confirmation times.As transactions are processed off-chain, they can be confirmed and settled almost instantly.This is a significant improvement from the main blockchain network, where confirmation times can take several minutes or even hours.Another benefit of this approach is its cost-effectiveness.With the scalability layer, fees for transactions are significantly lower compared to the main blockchain network.This makes it more feasible for businesses and individuals to use blockchain technology for everyday transactions.Furthermore, the scalability layer also promotes interoperability between different blockchain networks.As it is built on top of the main blockchain network, it can connect with other scalability layers, allowing for cross-chain transactions.This is a crucial step toward achieving a truly decentralized and interconnected blockchain ecosystem.The novelty of this work lies in its ability to provide a scalable solution for blockchain technology.By incorporating a second layer, it addresses one of the major challenges of blockchain and makes it more practical for real-world use.It also maintains the core principles of blockchain, such as security and decentralization, which are crucial for its widespread adoption.Some notable companies that have adopted Blockchain for peer-to-peer energy trading are reported in Table 2.

Blockchain Trilemma
The original Bitcoin blockchain introduced a 1-megabyte block size limit to defend against potential malicious attacks, particularly denial-of-service attempts.This constraint prevented an attacker from flooding the network with oversized fake data for mining, as blocks exceeding this limit would be rejected.However, in P2P energy trading and the broader energy sector, handling vast data volumes is a challenge.Real-time tracking generates data like kiloWatt-hours (kWh) produced, consumed, and transaction records.Processing this data at high rates can lead to congestion and higher fees.Blockchain's limitations, including scalability, security, and decentralization, as per Vitalik Buterin, present a dilemma.To address these challenges, it is crucial to consider the implications of blockchain-based energy trading.
Decentralization allows multiple network nodes, enhancing security, while scalability concerns transaction validation time and throughput.Scalability, a key issue in blockchain technology, involves trade-offs, such as security or decentralization.This balance is critical in energy trading.Blockchain-based P2P energy trading decentralizes transactions, reducing reliance on intermediaries.Varying consumption patterns lead to differing transaction volumes between prosumers and lower-energy households.Achieving this balance is essential for blockchain-based energy trading.The energy trading blockchain trilemma relates to trade-offs between scalability, security, and decentralization.Scalability challenges affect transaction processing speed and security.P2P energy trading relies on direct matching of energy supply and demand, emphasizing the need for a delicate balance within the trilemma.

Limitations of the Literature
Numerous scholarly articles have examined blockchain technology from a range of angles.As an illustration, Ref. [8] carried out a thorough systematic evaluation of the most recent studies on blockchain technology.Ref. [9] conducted quick research by interviewing people and completing an internal session to look into blockchain and distributed ledger technologies, concentrating on the benefits and limitations.In addition to exploring blockchain architecture and consensus techniques, Ref. [12] also identified potential patterns.Ref. [14] provided insights on blockchain technology in the context of P2P trading, nonprofit help, and energy trading in the context of B2B.Ref. [15] conducted a literature review and examined business models on blockchain solutions in the energy sector, focusing on technical challenges.Another review examined issues with peer-to-peer microgrids constructed using blockchain technology.Ref. [16] provided a description of how to incorporate game-theoretic techniques into energy trading through the P2P approach.
However, the existing literature does not specify the precise blockchain model for P2P trading and how it effectively addresses the blockchain trilemma.Second-layer solutions show promise in addressing the blockchain trilemma, but their optimal implementation in P2P energy trading for trilemma resolution remains uncertain.Several questions related to the blockchain trilemma persist: ■ Effectively managing the scaling of transactions that occur off the main blockchain and on the main blockchain, taking place within secondary sidechain and primary blockchain record-keeping systems, is the major challenge in terms of scalability [13].

■
With regards to security, the emphasis is on figuring out which protocols may be rolled out sideways reacting to dishonest or improper behaviors, as well as coming up with plans for handling a network that is overloaded [7].

■
In terms of decentralization, the central issue is how to uphold decentralization when incorporating off-chain transactions [3].

Systems for P2P Energy Trading Based on Blockchain Technology
A novel blockchain-based architecture that overcomes the hurdles of expansiveness, safety, and dispersion within the energy trading domain is instigating a revolution in P2P energy commerce [17].This model's core aim is to create a scalable, secure, and efficient environment for rapid and frequent energy trading.This is achieved through a second-layer solution built on a robust blockchain foundation.
In the world of blockchain P2P energy trading, there are two main participant types: "Energy network participants" encompass "prosumers" (those who both consume and produce energy) and "traditional consumers".These participants use the blockchain network to handle shared renewable energy transactions.Some also serve as blockchain miners, contributing computational power to maintain transaction accuracy.Block producers, responsible for processing transactions and creating blocks, fall under the miner category as stewards to the blockchain network [16,18].
Participants in P2P energy trades can draw energy depending on their production and consumption balance or send excess energy to the grid.Renewable energy contributions from prosumers are rewarded with remuneration, sometimes in the form of cryptocurrencies or crypto-utility tokens.Consumers benefit from competitive rates when purchasing energy using the same cryptocurrency [19].Pricing is determined by market conditions or a fixed token supply with variable renewable energy availability and is dependent on the dynamics of demand and supply for renewable energy that is currently available [20,21].
Figure 1 provides a visual representation of the distributed P2P connections, encompassing consumers, prosumers, and agents entrusted with three primary objectives: (i) equitable profit distribution among prosumers, (ii) collaborative contract deployment with prosumers, and (iii) optimization of energy trading bids [22].The proposed methodology for P2P energy trading consists of four main components: home miners, smart meters, storage devices, and an energy blockchain.Each of these components works together to create a seamless and efficient energy trading framework.Firstly, home miners refer to individuals or households that have their own renewable energy sources, such as solar panels or wind turbines.These home miners can generate their own electricity and can also store excess energy in their storage devices.This allows them to become energy producers rather than just consumers, which is a key aspect of P2P energy trading.Next, smart meters are used to measure and record the energy production and consumption of each home miner.These digital meters provide real-time data that can be accessed by both producers and consumers, allowing for accurate and transparent energy trading.Storage devices play a crucial role in the proposed methodology as they enable home miners to store their excess energy for later use.This is especially important for renewable energy sources, which are not always able to generate energy consistently.By using storage devices, home miners can ensure a steady supply of energy for themselves and have the option to sell their excess energy to other consumers.The final component of the proposed methodology is the energy blockchain.This is a digital ledger that records and verifies all energy transactions between home miners.The use of blockchain technology ensures secure and transparent transactions, as well as eliminates the need for intermediaries such as utility companies.This decentralized approach allows for a more efficient and cost-effective energy market.
Overall, the proposed methodology for P2P energy trading is a holistic approach that involves the active participation of individual energy producers and consumers.By utilizing renewable energy sources, smart meters, storage devices, and an energy blockchain, this framework has the potential to revolutionize the traditional energy market and create a more sustainable and resilient system.The adopted system architecture includes several key components that work together to achieve this scalability.The first component is the main blockchain network, which serves as the foundation for the entire system.This is where all the transactions are recorded and verified by the network participants.The second component is the scalability layer, which acts as a bridge between the main network and the applications.It is responsible for handling a higher volume of transactions and ensuring smooth and timely processing.One of the key features of the scalability layer is its ability to process transactions off-chain.This means that instead of every transaction being recorded on the main blockchain, it can be processed and verified on the scalability layer.This significantly reduces the burden on the main network, allowing it to handle more transactions without compromising its speed or security.Moreover, this approach The proposed methodology for P2P energy trading consists of four main components: home miners, smart meters, storage devices, and an energy blockchain.Each of these components works together to create a seamless and efficient energy trading framework.Firstly, home miners refer to individuals or households that have their own renewable energy sources, such as solar panels or wind turbines.These home miners can generate their own electricity and can also store excess energy in their storage devices.This allows them to become energy producers rather than just consumers, which is a key aspect of P2P energy trading.Next, smart meters are used to measure and record the energy production and consumption of each home miner.These digital meters provide real-time data that can be accessed by both producers and consumers, allowing for accurate and transparent energy trading.Storage devices play a crucial role in the proposed methodology as they enable home miners to store their excess energy for later use.This is especially important for renewable energy sources, which are not always able to generate energy consistently.By using storage devices, home miners can ensure a steady supply of energy for themselves and have the option to sell their excess energy to other consumers.The final component of the proposed methodology is the energy blockchain.This is a digital ledger that records and verifies all energy transactions between home miners.The use of blockchain technology ensures secure and transparent transactions, as well as eliminates the need for intermediaries such as utility companies.This decentralized approach allows for a more efficient and cost-effective energy market.
Overall, the proposed methodology for P2P energy trading is a holistic approach that involves the active participation of individual energy producers and consumers.By utilizing renewable energy sources, smart meters, storage devices, and an energy blockchain, this framework has the potential to revolutionize the traditional energy market and create a more sustainable and resilient system.The adopted system architecture includes several key components that work together to achieve this scalability.The first component is the main blockchain network, which serves as the foundation for the entire system.This is where all the transactions are recorded and verified by the network participants.The second component is the scalability layer, which acts as a bridge between the main network and the applications.It is responsible for handling a higher volume of transactions and ensuring smooth and timely processing.One of the key features of the scalability layer is its ability to process transactions off-chain.This means that instead of every transaction being recorded on the main blockchain, it can be processed and verified on the scalability layer.This significantly reduces the burden on the main network, allowing it to handle more transactions without compromising its speed or security.Moreover, this approach also reduces the transaction fees as the transactions on the scalability layer are processed at a lower cost compared to the main network.Another important component of our system architecture is the use of smart contracts.These are self-executing contracts that are built on top of the blockchain network and can automate the execution of specific tasks.By leveraging smart contracts, we can further improve the efficiency and scalability of our approach.For instance, we can use smart contracts to batch multiple transactions together, reducing the overall transaction fees and increasing the network's throughput.In addition to scalability, our approach also offers increased security.By separating the high-volume transactions from the main network, we are able to mitigate the risk of network congestion and potential attacks.This is because the scalability layer operates independently and is not affected by any disruptions on the main network.Furthermore, the use of blockchain technology ensures that all transactions are immutable and tamper-proof, providing an added layer of security to the entire system.
In the proposed use case study, we assume that Kahramaa (Qatar General Electricity & Water Corporation) employs specific pricing tariffs (see Table 3).Energy wholesalers provide energy at higher costs (e.g., USD 0.073 during peak hours and USD 0.0364 during off-peak periods) when energy demand exceeds network capacity.This incentivizes surplus renewable energy production, reducing energy prices and rewarding prosumers.Prosumers set their buying and selling prices, with trades occurring when prices align.Payment transactions in P2P energy trading are facilitated by blockchain.Transactions record the payer, payee, and payment amount.These are securely stored on a decentralized ledger using smart contracts.Smart contracts enforce rules for payment calculations based on energy tariff spot prices and consumption or production data from energy smart meters.They are programmable code segments acting as autonomous agents, eliminating the need for intermediaries or central authorities.Selling energy to the grid is priced at USD 0.02 per kiloWatt-hour (kWh) while buying energy from the grid costs USD 0.073 per kWh.
Selling energy to the grid is priced at USD 0.02 per kiloWatt-hour (kWh) and buying energy from the grid costs USD 0.0364 cents per kWh.
Transaction processing in P2P energy trading involves several crucial steps, as shown in Figure 2. It starts with P2P energy sharing between prosumers and consumers.Smart contracts then initiate payment transactions, utilizing tariff and energy data to calculate the payment amount.To ensure security, they are encrypted with methods like homomorphic encryption and grouped into a block.
Blockchain miners validate these transaction blocks and broadcast a candidate block to network nodes.Nodes collectively validate transactions through a consensus mechanism, ensuring that funds are available before authentication.The blockchain forms a linked list of blocks through hashing and common signatures, maintaining a comprehensive transaction history.Given blockchain's current limitations, second-layer solutions are explored to enhance transaction speed and capacity without compromising security.These solutions hold promise in addressing the blockchain trilemma.The study proposes a use case for second-layer solutions, sidechain processing of off-chain transactions, and network transaction fees as incentives for autonomous operation in blockchain-based P2P energy trading (see Figure 3).The pairing can occur between a prosumer and a consumer, and it can also be between two prosumers.
Energies 2024, 17, 915 9 of 18 verified through the participants' public keys.As long as they retain control over their private keys, no one else can sign on their behalf.The transaction block is stored in a sidechain, becoming its root.Figure 2 illustrates a payment limit of USD 1000, which the smart contract utilizes to calculate energy prices and ensure that the total transaction does not exceed this amount.Participants in this system agree to transactions beforehand, guaranteeing that all parties can complete many transactions as long as they have enough money in the payment channel.The commitment bond, a proof-of-stake consensus technique, is used to store off-chain transactions on a sidechain.Transaction fees serve as compensation for sidechain consensus.Within the sidechain, these transactions are arranged into a tree structure, with the depth of the tree growing as more users conduct trade.By enforcing verified through the participants' public keys.As long as they retain control over their private keys, no one else can sign on their behalf.The transaction block is stored in a sidechain, becoming its root.Figure 2 illustrates a payment limit of USD 1000, which the smart contract utilizes to calculate energy prices and ensure that the total transaction does not exceed this amount.Participants in this system agree to transactions beforehand, guaranteeing that all parties can complete many transactions as long as they have enough money in the payment channel.The commitment bond, a proof-of-stake consensus technique, is used to store off-chain transactions on a sidechain.Transaction fees serve as compensation for sidechain consensus.Within the sidechain, these transactions are arranged into a tree structure, with the depth of the tree growing as more users conduct trade.By enforcing Participants deposit a payment to commit an operation fee into a wallet with multiple signatories that acts as the contract's repository to start a smart contract.Let us say that A and B each contribute USD 300.Both parties sign the transaction digitally before it is uploaded to the blockchain for validation.These digital signatures authorize the transaction, verified through the participants' public keys.As long as they retain control over their private keys, no one else can sign on their behalf.The transaction block is stored in a sidechain, becoming its root.Figure 2 illustrates a payment limit of USD 1000, which the smart contract utilizes to calculate energy prices and ensure that the total transaction does not exceed this amount.
Participants in this system agree to transactions beforehand, guaranteeing that all parties can complete many transactions as long as they have enough money in the payment channel.The commitment bond, a proof-of-stake consensus technique, is used to store off-chain transactions on a sidechain.Transaction fees serve as compensation for sidechain consensus.Within the sidechain, these transactions are arranged into a tree structure, with the depth of the tree growing as more users conduct trade.By enforcing state changes inside chain hierarchies, this architecture creates a system that is resistant to fraud.The parties concerned must work together to close the channel or settle the dispute.According to the final amount following the previous transaction, reimbursements are distributed upon settlement.Participant A receives a USD 200 refund, and Participant B receives a USD 500 refund in Figure 2, which serves as an illustration of the final settlement.These settlements often take place at the conclusion of a predefined billing cycle, enabling participants to start new contracts for ongoing involvement.
The wholesaler or municipal authorities may need a comprehensive, auditable transaction record for legal and auditing reasons.In these circumstances, authenticated and recorded sidechain transactions might be encoded using cutting-edge techniques like zeroknowledge proofs [22].The electrical grid authority may securely maintain the most recent version of the whole sidechain ledger.P2P electrical transactions may be logged and invoiced on the blockchain at specified intervals, maybe in a span of five seconds or every 15 min.Second-layer recorded transactions provide efficient and quick procedures [23].This strategy permits rapid micropayments that can also pay transaction costs, unlike conventional bimonthly payments.
Off-chain transactions [24] remain off the blockchain, relying on bonded fraud proofs for enforcement, ensuring reliable autonomous network operation with minimal downtime.Penalties are imposed on fraudulent behavior.For final settlement transaction timing, a number of tactics can be used, such as predetermined time frames or based on the volume of trading transactions [25,26].The energy trading network could perform the same functions as the blockchain network, but it does not offer the same level of security advantages.Although simultaneous contract exits might overburden the network, the second-layer method lowers transaction fees and simplifies smart contract execution [27].In such cases, participants receive refunds, presenting a challenge for energy trading.Policies may need to impose fees or higher tariffs by the wholesale producer if smart contracts are not funded adequately.

Case Study of a P2P Energy Trade
Using information from the Education City Community Housing (ECCH) compound reported in Figure 4, this research seeks to estimate the volume of transactions and related costs in participant energy trading, considering both blockchain models and the cost reductions made possible by the second-layer solution.Using Hyperledger Fabric's smart contract, we've created a smart grid in which prosumers and consumers trade energy.The private blockchain network is established from GUI provided by Hyperledger Fabric and Solidity for writing smart contracts.Our model covers eight nodes in this study, with transactions taking place between a consumer and a prosumer.
Energies 2024, 17, x FOR PEER REVIEW 10 of 18 state changes inside chain hierarchies, this architecture creates a system that is resistant to fraud.The parties concerned must work together to close the channel or settle the dispute.According to the final amount following the previous transaction, reimbursements are distributed upon settlement.Participant A receives a USD 200 refund, and Participant B receives a USD 500 refund in Figure 2, which serves as an illustration of the final settlement.These settlements often take place at the conclusion of a predefined billing cycle, enabling participants to start new contracts for ongoing involvement.
The wholesaler or municipal authorities may need a comprehensive, auditable transaction record for legal and auditing reasons.In these circumstances, authenticated and recorded sidechain transactions might be encoded using cutting-edge techniques like zero-knowledge proofs [22].The electrical grid authority may securely maintain the most recent version of the whole sidechain ledger.P2P electrical transactions may be logged and invoiced on the blockchain at specified intervals, maybe in a span of five seconds or every 15 min.Second-layer recorded transactions provide efficient and quick procedures [23].This strategy permits rapid micropayments that can also pay transaction costs, unlike conventional bimonthly payments.
Off-chain transactions [24] remain off the blockchain, relying on bonded fraud proofs for enforcement, ensuring reliable autonomous network operation with minimal downtime.Penalties are imposed on fraudulent behavior.For final settlement transaction timing, a number of tactics can be used, such as predetermined time frames or based on the volume of trading transactions [25,26].The energy trading network could perform the same functions as the blockchain network, but it does not offer the same level of security advantages.Although simultaneous contract exits might overburden the network, the second-layer method lowers transaction fees and simplifies smart contract execution [27].In such cases, participants receive refunds, presenting a challenge for energy trading.Policies may need to impose fees or higher tariffs by the wholesale producer if smart contracts are not funded adequately.

Case Study of a P2P Energy Trade
Using information from the Education City Community Housing (ECCH) compound reported in Figure 4, this research seeks to estimate the volume of transactions and related costs in participant energy trading, considering both blockchain models and the cost reductions made possible by the second-layer solution.Using Hyperledger Fabric's smart contract, we've created a smart grid in which prosumers and consumers trade energy.The private blockchain network is established from GUI provided by Hyperledger Fabric and Solidity for writing smart contracts.Our model covers eight nodes in this study, with transactions taking place between a consumer and a prosumer.The balance of energy between prosumers (energy producers and consumers) that is formed by the dynamics of demand and supply of energy, determines the number of transactions.Energy demand occurs when energy import surpasses export, while an energy surplus results from the reverse scenario.Figure 5 illustrates the process of matching The balance of energy between prosumers (energy producers and consumers) that is formed by the dynamics of demand and supply of energy, determines the number of transactions.Energy demand occurs when energy import surpasses export, while an energy surplus results from the reverse scenario.Figure 5 illustrates the process of matching demand with supply to determine the number of transactions.Energy demand is rated and coupled with supply when there is a greater demand for energy than there is supply.While decreasing demand ranking produces the fewest transactions, ascending demand ranking produces the greatest number of deals.In contrast, supply is rated and matched with demand when supply is greater than demand.Transactions are maximized by a falling supply ranking, whereas they are minimized by an ascending ranking (see Figure 6).demand with supply to determine the number of transactions.Energy demand is rated and coupled with supply when there is a greater demand for energy than there is supply.While decreasing demand ranking produces the fewest transactions, ascending demand ranking produces the greatest number of deals.In contrast, supply is rated and matched with demand when supply is greater than demand.Transactions are maximized by a falling supply ranking, whereas they are minimized by an ascending ranking (see Figure 6).(2) where, : Entire energy consumption; : Total energy demand; : Nb of transactions.: Hours per day.For instance, "t" would be equal to 288 slots each day with 5 min settlements, whereas "t" would be equal to 48 slots per day with 30 min settlements; : Day's value, which in this case is 82 days; : Prosumer; : Prosumers; : Microgrids; demand with supply to determine the number of transactions.Energy demand is rated and coupled with supply when there is a greater demand for energy than there is supply.While decreasing demand ranking produces the fewest transactions, ascending demand ranking produces the greatest number of deals.In contrast, supply is rated and matched with demand when supply is greater than demand.Transactions are maximized by a falling supply ranking, whereas they are minimized by an ascending ranking (see Figure 6).(2) where, : Entire energy consumption; : Total energy demand; : Nb of transactions.: Hours per day.For instance, "t" would be equal to 288 slots each day with 5 min settlements, whereas "t" would be equal to 48 slots per day with 30 min settlements; : Day's value, which in this case is 82 days; : Prosumer; : Prosumers; : Microgrids; where, D: Entire energy consumption; S: Total energy demand; kt: Nb of transactions.t: Hours per day.For instance, "t" would be equal to 288 slots each day with 5 min settlements, whereas "t" would be equal to 48 slots per day with 30 min settlements; i: Day's value, which in this case is 82 days; p: Prosumer; P: Prosumers; G: Microgrids; ∆dx dx : Change in load; The consideration of horizons in energy trading mechanisms is crucial in ensuring efficient and effective energy markets (refer to Figure 7).One way in which horizons are being considered in energy trading mechanisms is through the use of different market products.The consideration of horizons in energy trading mechanisms also affects the way bids are accounted for.Bids refer to the offers made by market participants to buy or sell energy.In a single product market, all bids are considered for the same time horizon.This means that bids for both short-term and long-term contracts are accounted for in the same market, which may lead to inefficiencies and mispricing.Some energy markets have adopted a continuous product approach to address this issue, where bids for different time horizons are accounted for separately.This allows for more accurate pricing and better matching of supply and demand.In a single-product scenario, bids are accounted for in a straightforward manner.When a buyer places a bid for a product, it is recorded on the blockchain and can be seen by all participants in the marketplace.The seller can then choose to accept or reject the bid, and if accepted, the transaction is completed and recorded on the blockchain.This ensures that there is a clear and transparent record of the bidding process and the final sale of the product.
In a continuous product scenario, bids are accounted for in a more dynamic manner.The blockchain marketplace allows for real-time bidding on a product that is continuously available for sale.This means that multiple buyers can place bids on the product simultaneously, and the seller can choose to accept the highest bid at any given time.The bids are recorded on the blockchain, and the seller can see the current highest bid and the bidding history for the product.This creates a competitive and fair environment for buyers and sellers, as all bids are visible and cannot be tampered with.
The studied wholesale power market now has a 30-min settlement time.A 5-min settlement period will be implemented.The energy statistics for both minute settlements (30 and 15 min) are employed to determine the minimal and maximal transactions.The daily average of transactions is shown in Figure 8 for both the 5-min and 30-min time frames.Five-minute settlements varied from 260 to 1780 transactions in the ECCH experiment, and thirty-minute settlements ranged from 40 to 460 transactions.The red and blue curves stand in for these transactions.The blue curve representing the 30-min settlements shows a relatively steady and consistent level of transactions throughout the day, with a slight dip during the early morning hours.On the other hand, the red curve representing the 5-min settlements has a more volatile pattern, with peaks and dips throughout the day.This suggests that the 5-min settlement period will allow for more flexibility in trading, as there will be more opportunities to buy and sell power at different price points throughout the day.This could potentially lead to more efficient and competitive pricing in the wholesale power market.Additionally, the implementation of a 5-min settlement period could also lead to more accurate and timely settlement of transactions, as it would reduce the time lag between the time of trade and the time of settlement.This could help to reduce the risk and uncertainty for market participants, as they would have a more accurate and up-to-date understanding of their financial positions.However, there may also be challenges in implementing a 5-min settlement period, such as the need for updated and advanced technology to handle the increased frequency of settlements.Overall, the shift toward a 5-min settlement period in the wholesale power market shows a commitment to continuously improving and modernizing the energy sector in order to meet the evolving needs and demands of the market.This change has the potential to bring about positive changes in the market, and it will be interesting to see how it affects the overall dynamics of the wholesale power market in the future.When evaluating the costs of blockchain fees on the Hyperledger Fabric (HF) blockchain, it is important to consider the additional fees associated with the blockchain technology.These fees can vary depending on the type of blockchain network being used and the type of transactions being made.For example, the fees associated with transactions on the public Ethereum When evaluating the costs of blockchain fees on the Hyperledger Fabric (HF) blockchain, it is important to consider the additional fees associated with the blockchain technology.These fees can vary depending on the type of blockchain network being used and the type of transactions being made.For example, the fees associated with transactions on the public Ethereum blockchain are typically higher than those associated with the private HF blockchain.For example, transactions that involve smart contracts may incur additional fees due to the complexity of the execution logic.Additionally, the fees associated with deploying and running a smart contract may be higher than the fees associated with a regular transaction.Furthermore, the fees associated with deploying and running a dApp on the HF blockchain may be higher than the fees associated with a normal transaction.Additionally, the fees associated with running a permissioned network may be higher than those associated with a public blockchain.Finally, the fees associated with running a private network may be higher than those associated with a public blockchain [18].
The cost of using Hyperledger Fabric (HF) to process transactions in USD depends on a variety of factors, such as the particular blockchain network size and the number of nodes, the number of transactions per second, the complexity of the transaction, and the amount of data stored in the chain.In general, the cost per transaction in Hyperledger Fabric is lower compared to other distributed ledger technologies since its permissioned and private architecture allows for more efficient data processing and storage.Moreover, the use of smart contracts and other features, such as consensus algorithms, enable the network to run more efficiently, reducing the cost per transaction.Since Hyperledger Fabric is an open-source platform, the cost of running the network is determined by the cost of setting up and running the nodes and is dependent on the resources required to run the network.Additionally, there are certain fees associated with the use of the network, such as transaction fees and gas fees, which can be paid in USD or other currencies.Overall, the cost of using Hyperledger Fabric to process transactions in USD is relatively low compared to other blockchain networks.
Equation (3) outlines the calculation for HF blockchain transaction costs, which are based on the size of the transaction in bytes and the transaction fee rate set by the network.The equation is as follows: Cost = Size × Fee Rate ( For example, if the size of a transaction is 150 bytes and the fee rate is 0.001 ETH, the cost of the transaction would be 0.15 EneToken (Native currency created with chaincode for HF).When a customer makes a purchase using EneToken, the value of the transaction is first converted to US dollars based on the current exchange rate.The customer's EneToken wallet is then debited the equivalent amount in EneToken, while the merchant's account is credited with the converted US dollar amount.This process ensures that both parties are aware of the exact amount being transacted and eliminates any confusion or discrepancies.The fee rate is determined by the network, and it can vary depending on the current network load and the specific blockchain protocol.As a general rule, larger transactions tend to have higher fees, and if the fee rate is too low, the transaction may not be accepted by the network.It is important to research the fee rate of the network before submitting a transaction in order to ensure that the cost of the transaction is not too high and that it will be accepted by the network.Additionally, some networks allow users to set their own fee rate, which can be a useful tool for controlling the cost of transactions.Figure 9 displays the daily average cost per transaction over the course of two months.Equation ( 4) provides the computation of the overall blockchain costs.
For 50 properties over a period of two months, Figure 10 shows the lowest and maximum number of transactions and related expenditures.By utilizing a second-layer method, the block finality time-the length of time it takes for transactions to be recorded on the blockchain-can be configured to lower computational costs for each transaction.This has a significant impact on cost reductions.The maximum transaction cost was determined by the cost that occurred on 8 August 2019, while the minimum cost was calculated using the cost noted on 8 September 2019.Equations ( 5) and ( 6) illustrate the computation for the minimum and maximum costs of the second-layer solution:  For 50 properties over a period of two months, Figure 10 shows the lowest and maximum number of transactions and related expenditures.By utilizing a second-layer method, the block finality time-the length of time it takes for transactions to be recorded on the blockchain-can be configured to lower computational costs for each transaction.This has a significant impact on cost reductions.The maximum transaction cost was determined by the cost that occurred on 8 August 2019, while the minimum cost was calculated using the cost noted on 8 September 2019.Equations ( 5) and ( 6 Here, tmin corresponds to 8 September, and tmax corresponds to 8 August 2019.Figure 11 compares the costs of blockchain solutions with and without implementations at the second layer, as well as the total and % of money saved.Savings vary from 95% to 98% when comparing the cost of employing the second-layer technique to the cost of registering each transaction on the blockchain.For 50 properties over a period of two months, Figure 10 shows the lowest and maximum number of transactions and related expenditures.By utilizing a second-layer method, the block finality time-the length of time it takes for transactions to be recorded on the blockchain-can be configured to lower computational costs for each transaction.This has a significant impact on cost reductions.The maximum transaction cost was determined by the cost that occurred on 8 August 2019, while the minimum cost was calculated using the cost noted on 8 September 2019.Equations ( 5) and ( 6 Here, tmin corresponds to 8 September, and tmax corresponds to 8 August 2019.Figure 11 compares the costs of blockchain solutions with and without implementations at the second layer, as well as the total and % of money saved.Savings vary from 95% to 98% when comparing the cost of employing the second-layer technique to the cost of registering each transaction on the blockchain.Here, t min corresponds to 8 September, and t max corresponds to 8 August 2019.Figure 11 compares the costs of blockchain solutions with and without implementations at the second layer, as well as the total and % of money saved.Savings vary from 95% to 98% when comparing the cost of employing the second-layer technique to the cost of registering each transaction on the blockchain.
The proposed two-layer blockchain has the potential to revolutionize the way we use and interact with technology.One of the biggest benefits of this new system is its applicability.Unlike traditional blockchains, which are limited to specific use cases, the two-layer blockchain can be used in a diverse range of industries and applications.This opens up a world of possibilities for businesses and individuals alike, as they can now leverage the power of blockchain technology in ways that were previously unavailable to them.In addition to its applicability, the two-layer blockchain also offers a unique advantage in terms of renewable energy.The system is designed to maximize the use of renewable energy sources within the community.This means that the energy used to power the blockchain is sourced from sustainable sources, such as solar, wind, or hydropower.Not only does this benefit the environment by reducing our reliance on fossil fuels, but it also has a positive impact on the local community by promoting the use of clean energy sources.The proposed two-layer blockchain has the potential to revolutionize the way we use and interact with technology.One of the biggest benefits of this new system is its applicability.Unlike traditional blockchains, which are limited to specific use cases, the two-layer blockchain can be used in a diverse range of industries and applications.This opens up a world of possibilities for businesses and individuals alike, as they can now leverage the power of blockchain technology in ways that were previously unavailable to them.In addition to its applicability, the two-layer blockchain also offers a unique advantage in terms of renewable energy.The system is designed to maximize the use of renewable energy sources within the community.This means that the energy used to power the blockchain is sourced from sustainable sources, such as solar, wind, or hydropower.Not only does this benefit the environment by reducing our reliance on fossil fuels, but it also has a positive impact on the local community by promoting the use of clean energy sources.
Furthermore, the two-layer blockchain has the potential to significantly reduce the cost of transactions.This is due to the fact that the system operates on two separate layers-the main layer and a secondary layer.The main layer is responsible for processing and verifying transactions, while the secondary layer handles more complex tasks, such as smart contracts.By separating these tasks, the system is able to process transactions at a much faster and more efficient rate, resulting in lower transaction fees.This is a huge advantage for businesses and individuals who are looking to save on transaction costs and increase their profit margins.Overall, the proposed two-layer blockchain offers a multitude of benefits that have the potential to greatly impact our society.From its wide applicability to its focus on renewable energy and cost efficiency, this new system has the potential to revolutionize the way we interact with technology and conduct transactions.As we continue to move toward a more digital and sustainable future, the two-layer blockchain has the potential to play a key role in shaping the way we live and do business.

Conclusions
Within the framework of the energy trading blockchain trilemma, the objective of this research is to provide a comprehensive evaluation of the status of scaling solutions.Even though peer-to-peer (P2P) energy trading is still in its infancy, blockchain technology has recently attracted more interest since it offers great promise for revolutionizing the way that energy is distributed.The industry has also witnessed the emergence of numerous startups.The success of energy trading depends on several important aspects, including technical improvements as well as regulatory, legal and economic, legal, and regulatory issues.For instance, transaction processing costs are far lower than the existing Furthermore, the two-layer blockchain has the potential to significantly reduce the cost of transactions.This is due to the fact that the system operates on two separate layers-the main layer and a secondary layer.The main layer is responsible for processing and verifying transactions, while the secondary layer handles more complex tasks, such as smart contracts.By separating these tasks, the system is able to process transactions at a much faster and more efficient rate, resulting in lower transaction fees.This is a huge advantage for businesses and individuals who are looking to save on transaction costs and increase their profit margins.Overall, the proposed two-layer blockchain offers a multitude of benefits that have the potential to greatly impact our society.From its wide applicability to its focus on renewable energy and cost efficiency, this new system has the potential to revolutionize the way we interact with technology and conduct transactions.As we continue to move toward a more digital and sustainable future, the two-layer blockchain has the potential to play a key role in shaping the way we live and do business.

Conclusions
Within the framework of the energy trading blockchain trilemma, the objective of this research is to provide a comprehensive evaluation of the status of scaling solutions.Even though peer-to-peer (P2P) energy trading is still in its infancy, blockchain technology has recently attracted more interest since it offers great promise for revolutionizing the way that energy is distributed.The industry has also witnessed the emergence of numerous startups.The success of energy trading depends on several important aspects, including technical improvements as well as regulatory, legal and economic, legal, and regulatory issues.For instance, transaction processing costs are far lower than the existing coordination costs, enabling more frequent energy trading that can fully realize the promise of renewable energy.While maintaining the security of P2P trading against participant misbehavior, criminal activity, and fraud is essential, competitive pricing for energy providers and prosumers can further encourage the renewable energy market.
While these solutions show promise in improving scalability, they also bring their own set of challenges.For instance, layer two solutions require more complex smart contracts and can potentially compromise the decentralization and security of the network.Sharding and sidechains also require significant changes to the existing blockchain infrastructure, making them more difficult to implement.Apart from technical solutions, there are also regulatory and legal barriers that need to be addressed for the successful adoption of blockchain-based energy trading.The lack of regulatory frameworks and standards for energy trading on the blockchain can hinder its growth and adoption.Additionally, legal issues such as data privacy and protection of consumer rights need to be addressed to build trust in technology.Furthermore, the economic aspect of blockchain-based energy trading is also crucial.The success of P2P trading relies on competitive pricing for both energy providers and prosumers.However, the current volatility of cryptocurrency prices and the lack of stable pricing mechanisms can make it challenging to achieve this goal.To overcome these challenges, collaboration between stakeholders, including energy companies, regulators, and technology providers, is essential.Regulatory frameworks need to be developed to ensure the security and transparency of energy trading on the blockchain.Moreover, partnerships between energy companies and blockchain startups can help in the development of more efficient and scalable solutions.
In conclusion, while blockchain technology holds great potential for revolutionizing the energy distribution industry, its widespread adoption and success depend on addressing the trilemma of scalability, security, and decentralization.The current status of scaling solutions shows promise, but further research and development are necessary to overcome the technical, regulatory, and economic challenges.Collaboration and partnerships between stakeholders will be crucial in shaping the future of energy trading on the blockchain.

Figure 1 .
Figure 1.Proposed Use Case for the Blockchain-based P2P trading.

Figure 2 .
Figure 2. P2P trading utilizing Blockchain technology: the proposed framework involves the installation of smart meters in every household, whether the individual is a prosumer or consumer.The two parties involved in the transaction are referred to as A and B, representing the prosumer and consumer, respectively.For simulation purposes, the set cost for the transaction is USD 300.

Figure 2 .
Figure 2. P2P trading utilizing Blockchain technology: the proposed framework involves the installation of smart meters in every household, whether the individual is a prosumer or consumer.The two parties involved in the transaction are referred to as A and B, representing the prosumer and consumer, respectively.For simulation purposes, the set cost for the transaction is USD 300.

Figure 2 .
Figure 2. P2P trading utilizing Blockchain technology: the proposed framework involves the installation of smart meters in every household, whether the individual is a prosumer or consumer.The two parties involved in the transaction are referred to as A and B, representing the prosumer and consumer, respectively.For simulation purposes, the set cost for the transaction is USD 300.

Figure 5 .
Figure 5. Aligning the need for energy with the available energy supply.

Figure 6 .
Figure 6.Transaction's average cost per day in U.S. Dollars.The number of transactions (TX) over a two-month period is determined by computing Equation (1) for the lowest number of transactions and Equation (2) for the greatest amount.minNo.TX = ∑ min 82 =1 ==

Figure 5 .
Figure 5. Aligning the need for energy with the available energy supply.

Figure 5 .
Figure 5. Aligning the need for energy with the available energy supply.

Figure 6 .
Figure 6.Transaction's average cost per day in U.S. Dollars.The number of transactions (TX) over a two-month period is determined by computing Equation (1) for the lowest number of transactions and Equation (2) for the greatest amount.minNo.TX = ∑ min 82 =1 ==

Figure 6 .
Figure 6.Transaction's average cost per day in U.S. Dollars.The number of transactions (TX) over a two-month period is determined by computing Equation (1) for the lowest number of transactions and Equation (2) for the greatest amount.minNo.TX = ∑ 82 i=1 D==S ∆px px : Change in price; εxx: Elasticity factor; ∆px: Supply-Demand Ratio.Energies 2024, 17, 915 12 of 18

Figure 7 .
Figure 7. Transaction's average cost per day in U.S. Dollars.Figure 7. Transaction's average cost per day in U.S. Dollars.

Figure 7 .
Figure 7. Transaction's average cost per day in U.S. Dollars.Figure 7. Transaction's average cost per day in U.S. Dollars.

Figure 8 .
Figure 8. Number of Transactions per day.

Figure 8 .
Figure 8. Number of Transactions per day.

Figure 9 .
Figure 9. Average Daily Cost per Transaction in U.S. Dollars with the x-axis representing the transaction cost in USD ($) and the y-axis representing the date.

Figure 10 .
Figure 10.#Nb-TX and the cost in USD.

Figure 9 .
Figure 9. Average Daily Cost per Transaction in U.S. Dollars with the x-axis representing the transaction cost in USD ($) and the y-axis representing the date.

Figure 9 .
Figure 9. Average Daily Cost per Transaction in U.S. Dollars with the x-axis representing the transaction cost in USD ($) and the y-axis representing the date.

Figure 10 .
Figure 10.#Nb-TX and the cost in USD.Figure 10. #Nb-TX and the cost in USD.

Figure 10 .
Figure 10.#Nb-TX and the cost in USD.Figure 10. #Nb-TX and the cost in USD.

Figure 11 .
Figure 11.Maximum costs and cost savings with/without two-layer (L2) solution.

Table 3 .
Pricing structures during periods of high and low demand in a specific case study.