Integrating Forecasting Service and Gen2 Blockchain Into a Local Energy Trading Platform to Promote Sustainability Goals

Peer-to-peer (P2P) trading in a local energy market (LEM) offers various participants the opportunity to negotiate and strike energy deals among themselves using a distributed ledger technology called blockchain. In this paper, a new local model is presented using a layer-2 scalability solution for second-generation (Gen2) blockchain technology to enable P2P trading among four types of participants: consumers, prosumers with solar photovoltaic (PV) systems, prosumers with solar PV systems and battery energy storage systems (BESSs), and electric vehicles (EVs). The proposed LEM trading platform involves several critical steps, including the creation of typical forecasting profiles for load consumption, solar generation, and battery state-of-charge (SOC) through a forecasting solution. Next, the LEM participants place their pricing bids using a trading agent service, and the trading engine collects the profiles data and bid prices, which performs matchmaking in a forward-facing market. The output of the trading engine consists of dispatch signals for prices and energy values that are sent to each participant to execute actual trading. Furthermore, the trading engines store the accepted and past bidding data and energy values of P2P trades for each participant in blockchain technology, which can be retrieved and displayed on the LEM user interface screens of participants and administrators using their blockchain addresses at any time during the trading process. This study focuses on simulating proposed LEM models, incorporating functional limitations and market rules. These rules aim to reduce energy costs, enhance margins for utilities and retailers, and mitigate grid congestion through BESSs, resulting in reduced operational and capital expenditure. LEM outcomes are analysed and compared with a Business-as-usual (BAU) model. Participants’ energy trading behaviour, cost-revenue dynamics, grid impact, and blockchain implementation costs are explored. The study highlights LEM benefits in terms of reduced CO2 emissions by 984 kg CO2, increased self-sufficiency by 2.2%, and improved financial benefits of all participants by 21.6%. The use of modern blockchain technology guarantees secure data storage and rapid, cost-effective energy trading, thereby making the proposed LEM platform a viable solution in the distribution market.


I. INTRODUCTION
In recent years, the concept of the LEM has attracted substantial attention in the realm of energy markets.A LEM can be regarded as a sub-energy market that aims at facilitating local energy scheduling, management, trading, and integration into power grids by following consensus-based market rules and regulations [1].A LEM characteristically operates through mutual negotiations between consumers and prosumers (consumers with solar PV systems), which distinguishes it from existing distributed energy resources (DER) management systems like distributed resource management systems (DERMS) and advanced distribution management systems (ADMS) [2].One main feature of LEM is P2P trading, which enables prosumers and consumers to simultaneously trade energy among one another in a decentralised manner to fully control small-scale DERs and function as independent energy contractors [3].To support smart contracts for energy trading between diverse prosumers and consumers, a distributed ledger platform like blockchain can be employed [4] Despite the fact that mutually agreed-upon P2P transactions among prosumers and consumers in the LEM can benefit many different entities, there are several challenges, including the need for infrastructure such as smart meters, associated with P2P energy trading.One of the most crucial facets that P2P trading needs to guarantee is the financial rewards for each entity participating in the LEM.Without these incentives, there may be little motivation for participants to move away from existing BAU contracts and engage with the LEM [5].Another aspect is the assured advantage of managing the power grid by repeatedly coordinating with the LEM [6].Additionally, it is necessary to determine the economic advantages of various other distribution utilities, such as energy retailers, network operators, and market operators, to introduce the LEM in practice [7].On top of that, all the power network's physical restrictions must be always adhered to while P2P contracts are being settled among the LEM participants [8].
Numerous recent research studies prioritise prosumers' and consumers' preferences to encourage them to participate in P2P trading in LEM.The authors in [9] and [10] propose suitable business models after undertaking an analysis of prosumers' and consumers' preferences.Prosumers and consumers are allowed to express their preferred P2P trading volumes, prices, time frames, and partners in a competitive LEM in [11].Prosumers and consumers are also provided with the option to engage in P2P trading either individually [12] or collectively [13], depending on their preferences.To get the most out of the LEM through P2P trading, it is advised in [14] to make effective P2P trading decisions.Differences in trust are the main player in P2P trading decisions, according to the authors of [15], even though other factors such as political orientation, location attachment, and climate change, are also important.

A. RELATED WORK 1) ELECTRICITY COST REDUCTION
Reduced electricity costs are one of the major factors, according to [16], that can significantly affect P2P trading decisions in the LEM.This reality is acknowledged by the authors of [17], who then create an optimum P2P decision-forming method that ensures a reduction in LEM participants' energy bills.LEM participants are instructed to transact between feed-in-tariff (FiT) rates and time-of-use (ToU) tariffs in [18] to make P2P trading profitable for both buyers (who can both be prosumers and consumers) and sellers (who can be prosumers only).To further reduce their energy expenditures by rearranging their energy usage behaviours, the authors in [19] also introduce the concept of P2P negawatt trading in the LEM.In addition, P2P trading in the LEM is examined from the standpoint of social efficiency in [20] to increase LEM participants' preference for it.Moreover, in [21], a comparative study on the ideal sizing and economic analysis of a P2P trading-based microgrid is also conducted.
However, these studies do not consider the interests of other stakeholders, such as energy retailers and distribution utilities, which are addressed in this paper.

2) USE OF STORAGE SYSTEMS
The utilisation of storage systems in a P2P trading-driven LEM is emphasised in [22], as LEM participants can attain a greater level of flexibility while striking both buying and selling deals with their partners.For instance, the application of BESSs, one type of energy storage system, in smart P2P trading-based systems is acknowledged in [23].The authors in [24] adopt BESSs to benefit LEM participants by autonomously governing their generation, consumption, and energy exchange.An electricity cost-minimised P2P trading mechanism for residential customers with solar PV and BESS is formulated [25].A robust optimisation technique is developed in [26] to determine the optimum price of P2P trading considering BESSs.A shared BESS-enabled P2P trading framework is proposed in [27].Additionally, the benefits of coordinated P2P trading and BESSs to back up a power grid are investigated in [28].
EVs are another form of storage system that can be used as a source for settling P2P transactions in the LEM.The unused stored energy in the EVs can be discharged and sold in the LEM.Also, EVs can be charged in accordance with the preferences of the owners by using the available energy of their trading partners [29].The inclusion of EVs in the LEM is recommended in [30] to ascertain P2P trading flexibility under various supply-demand scenarios.An investigation is carried out in [31] to find out the contributions of EVs in P2P trading.A cryptocurrency-empowered billing system is designed in [32] that allows LEM participants to conduct P2P charging of EVs.A secure P2P trading framework, both intra-regional and inter-regional, for EVs is modelled in [33].Furthermore, an entirely decentralised P2P trading strategy is structured in [34] by taking both battery storage systems and EVs into account.
While the aforementioned studies prioritise the management of BESSs and EVs in P2P trading-based LEM models, this paper extends those approaches by making sure solar PV surplus in the LEM is utilised first to minimise superior grid export, which otherwise may create network issues.

3) FORECASTING AND BLOCKCHAIN PLATFORMS
Existing studies have also focused on developing effective forecasting models and P2P information sharing platforms.As for forecasting LEM demand and supply, the implications of forecasting errors in P2P trading are inspected in [35].A mechanism to support demand forecast error assessment in the LEM is proposed in [36].Another model is developed in [37] to mitigate imbalances in the LEM through accurate forecasting.Further, the application of artificial intelligence (AI)-based approaches is also noticeable in the existing literature, which may contribute to improving forecasting services.For example, a continuous data stream-based learning approach is proposed in [38].A deep learning approach is structured for neural networks in [39].A deep learningassisted big data approach is also developed in [40].
In the recent past, blockchain has emerged as a type of information sharing platform that can track and store P2P transactions in a transparent manner [41].The authors in [42] structure token-based P2P trading using blockchain technology.P2P trading information is documented in an immutable fashion in [43].The blockchain platform is also used to settle smart contracts [44], organise P2P auctions [45], arrange multi-settlement quasi-ideals [46], determine P2P trading prices [47], and match supply with demand [48].A smart contract-configured energy exchange mechanism is outlined in [49], that can be reused by employing a set of verification rules.The authors in [50] design smart contracts to exchange data on a cloud-based system securely, which can also be applied in LEM.
The performance evaluation of a blockchain-based P2P trading system is also executed in [51].The authors in [52] outline a secured blockchain-empowered decentralised transaction system to carry out P2P transactions transparently.A blockchain-based secured incentive scheme for energy delivery is proposed in [53].A similar approach is also employed in [54] and [55] to involve the publicly accessible charging infrastructure and develop an advanced climate-aware agriculture system, respectively.
In contrast with these studies, this paper uses an advanced Gen2 blockchain technology, integrated with the forecasting service, to secure data storage and quick data retrieval with the purpose of developing a viable LEM solution.A comparative analysis of the existing literature is also provided in Table 1.

B. RESEARCH GAPS
Undoubtedly, the existing studies have greatly contributed to organising P2P contracts among LEM participants.However, consideration of the energy retailer and distribution utility is mostly absent.This paper ensures their participation in the P2P trading-driven LEM without sacrificing their BAU margins since they are also crucial entities in an electricity network.To address this gap, a blockchainenabled forward-facing P2P trading framework in the LEM is proposed, ensuring the involvement of both participants and other stakeholders.The use of blockchain creates trust in transaction outcomes due to its immutable record, allowing LEM participants and stakeholders to store data securely and retrieve past P2P trading information and data.Further, a forecasting solution is integrated with the proposed LEM model to generate accurate profiles of solar PV systems, loads, and batteries.Finally, the economic assessment of the proposed LEM mechanism is carried out using real-world data, and the results are compared with the BAU to highlight the superior performance.

C. CONTRIBUTIONS
This paper focuses on the development of a LEM framework, coupled with its integration with forecasting and blockchain technology.This integration enables the execution of P2P transactions in a decentralised manner, ensuring the financial interests of all involved entities.This approach holds promise for practical implementation and real-world deployment.The energy and information flows for the proposed LEM platform are shown in Fig. 1.Nevertheless, the key contributions of this paper are outlined as follows: • Developing a LEM platform based on Gen2 blockchains, to enable secure P2P trading among participants and store all bidding and transaction information transparently.
• Developing a forecasting service to generate typical profiles of load consumption, solar PV generation, and BESS SOC, to enable energy trading ahead of real-time.
• Integrating trading agent and trading engine services to collect bid prices and facilitate matchmaking in a forward-facing fashion.
• Proposing a P2P trading-based LEM to guarantee tangible benefits for all participants, stakeholders, and the environment by providing monetary gains, confirming margins and network integrity, and reducing CO 2 emissions, respectively.
The structure of the rest of the paper is as follows.
Section II provides an explanation of the overall architecture of the LEM, retailer participation, and user interfaces (UIs).Section III and Section IV present forecasting services and the integration of blockchain technology, respectively.Section V elaborates on the mathematical formulation of the proposed LEM model.Section VI outlines the explanation of the input parameters used in the proposed model.The findings and their analysis are presented in Section VII.Lastly, Section VIII concludes the paper with final remarks and outlines potential directions for future research.

II. LOCAL ENERGY MARKET ARCHITECTURE AND OPERATION
LEM functions as a localised iteration of a conventional electricity market, operating within a specific region.It offers a platform for various participants and stakeholders to engage in trading while adhering to network limitations.P2P energy trading embodies a form of collaborative bargaining to manage local energy exchange and pricing.This activity is commonly facilitated by a distributed ledger-based platform, often utilising blockchain technology.P2P trading is designed to motivate participants to participate in the LEM, promote frequent energy transactions between participants, and minimise electricity bills while balancing the community's energy requirements.Participants can trade individually or as a group, and network operators are involved to make the platform functional.P2P energy trading allows participants with solar PV systems to sell excess electricity directly to other participants, without going through a utility company.This can help lower the cost of electricity for all participants, regardless of their income.P2P energy trading has the potential to revolutionise the way energy is generated and consumed.By making it easier for participants to sell excess electricity, P2P energy trading could help level the playing field and make renewable generation more accessible to everyone.Figure 1 depicts the physical layout of the LEM designed to accommodate four types of participants including consumers, prosumers with solar PV systems, prosumers with solar PV systems and BESSs, and EVs.Prosumers can participate in the LEM as buyers and sellers; however, traditional consumers are only able to purchase energy from the LEM.EVs are flexible loads that can buy energy from LEM to charge their BESS.The proposed network consists of four feeders under a single substation, which comprises 20 participants, including eight consumers, eight prosumers with solar PV, three prosumers with solar PV systems and BESS, and one EV.A single retailer is accountable for ensuring that energy requirements are adequately met and for conducting monthly settlement and billing processes.
The LEM development platform services are shown in Figure 2, which mainly consist of a UI, LEM trading platform, and blockchain.Participants and admin users have different UI screens, which connect the users with the LEM trading platform and blockchain.Participants can place their bid offers and view their trade summaries on their UI screen.Admin users have the ability to onboard new users, manage forecasting and view the LEM trade summary on their UI screen.The LEM trading platform receives the forecasted profiles, participants' bidding information, and retailer tariff details for matchmaking mechanisms.The forecasting service provides forecasted profiles of load, solar PV generation, and BESS's SOC.A central database (DB) stores all the data, including the bid, trading, billing, and settlement data.Web3 Interface connects all users and DB with blockchain.Blockchain stores the most important P2P trading data (past bids and P2P traded volume).
Figure 3 illustrates the intricate operational sequence of the LEM Trading Engine, a core component within the LEM trading platform as shown in Figure 2. Participants use the UI to send their energy buy or sell bid offer (the bid energy price) before the bidding window closes.The bid prices are received by the LEM platform, which stores them in a DB.The forecasting service generates profiles for load consumption, solar PV generation, and BESS SOC based on baseline profiles and actual meter data and saves them in a DB.The trading engine pulls bid data and forecasted energy profiles from the DB for each time interval and performs optimised matchmaking in a forward-facing market to calculate the volume of P2P energy trading and the price at which the energy is traded.Energy traded with the grid is also recorded.The total cost or revenue for each participant is calculated in both BAU and LEM cases, and all the data is stored in the DB.

A. LEM FUNCTIONAL LAYERS AND RETAILER PARTICIPATION
Figure 4 depicts the functional layers of the LEM system.The LEM comprises three essential layers: the control signal layer, the energy flow layer, and the billing and settlement layer.Within the energy flow layer, the physical layer of the electrical network is showcased.Specifically, it illustrates a scenario involving a prosumer and a consumer.In this example, 1 kWh of P2P energy trading occurs from the prosumer to the consumer, and their residual energy is exchanged with the distribution utility.The control signal layer is responsible for overseeing P2P energy trading.Here, users' bidding and forecasting information are communicated to the LEM trading platform.Notably, blockchain technology is employed to securely store this data.Additionally, the trading platform's outputs are displayed on UI screens and sent to the retailer.The retailer, functioning within the billing and settlement layer, takes on the responsibility of ensuring that users' energy requirements are met.Accordingly, billing information is sent to each user based on the final settlement.To exemplify this process, the figure presents a peak time instance where a prosumer sells 1 kWh at a rate of 20.11c (the P2P energy price in the LEM), while a contracted consumer pays 51.87c to acquire 1 kWh.This combined price includes various components, such as the P2P energy price (20.11c), network fee (27.26c),LEM platform cost (0.50c), energy retailer margin (2.5c), and taxes (1.50c).
This paper investigates the LEM model with the inclusion of a sole energy retailer [56].In order to optimise advantages for energy consumers and enhance P2P trading activities, a ToU tariff structure is applied.This subsection focuses on P2P trading within the context of a single energy retailer-based LEM model.retailer margin remain unaltered and are paid with every LEM trade.

B. DATA COLLECTION AND USER INTERFACES
The LEM data collection service allows participants to post metering data including consumption, generation and battery, and trade prices to the platform.The LEM trading platform constantly monitors and forecasts the status of solar generation, load consumption, BESS SOC, and energy prices.Participants can place buy and sell orders within predetermined limits to participate in the trading engine's merit order mechanism.The outcomes of the LEM trading engine are analysed and displayed in the user interface, along with a forecasted trade summary.Successful transactions involving BESS are then transmitted to a dispatch service that executes the dispatch process in real-time.The fundamental objectives of this P2P-supported LEM platform are threefold: firstly, to decrease energy expenses for users; secondly, to sustain profit margins for energy retailers and distribution utilities; and thirdly, to guarantee the practical feasibility of implementing the LEM in real-world scenarios.The LEM model employs a singular retailer strategy for energy trading between sellers and buyers, thereby ensuring that predetermined margins are distributed in an appropriate manner among distribution utilities, trading platforms, upstream energy retailers, and relevant government entities.
The UIs of the LEM platform for participants and admin users are shown in Figure 5.The UI for participants contains three parts.In the first part, participants can place their bid offer in the bidding window.The second part displays the trading information for the selected time interval and the past data of the participant.P2P energy traded, cost/revenue breakdown, and the cost/benefit of using LEM are displayed with graphs.In the third part, the information stored on the blockchain related to the participant is displayed on UI dashboards for the selected time interval.The bid amount, P2P traded volume, price, and benefit of using LEM are displayed in the third section.Similarly, the UI for admin, as shown on the right side of Figure 5, consists of three sections and a forecasting service.In the first part, the LEM trading summary status is displayed.P2P trading volume and rate for the top three participants are displayed.In the second part, the impact of LEM vs. BAU is shown.The total cost benefit of using LEM for energy self-sufficiency is displayed along with graphs.In the third part, the information stored on the blockchain is displayed.

III. FORECASTING SERVICE
As shown in Figure 6, the forecasting service provides baseline (default) profiles for the residential load, solar PV generation and BESS SOC profiles using a T-shirt sizing approach, which will be the basis of the LEM trading of excess and deficiencies.The accuracy of the forecast is therefore directly related to the outcome of trading versus actual settlement.To achieve this, we have different options, including asking users to provide some basic details about their load consumption pattern.To find an accurate forecast for each meter, a generic starting profile called a baseline profile is defined for similar meter types and adapted for each meter as actual readings come in.In this case, each meter will have a baseline profile suitable for their consumption or generation patterns and will improve in accuracy over time based on their meter readings.P2P trading requires four data entries from four end user types on the sub-meter level linked with meter and time information.Sub-meters are load, generation, and BESS SOC.For consumers, sub and main meter are considered equal.For instance, Users: consumers, prosumers, prosumers with BESS, and EV; data types: load, generation, BESS SOC, and BESS energy rate.Based on BESS behaviour for charging excess solar PV and offsetting behind-the-meter (BTM) load requirements, accurate calculations can be made.These values feed as constraints into the BESS LEM orders.
The forecast readings generated by the forecasting service adopt a typical load approach, using historical meter readings from the applicable utility and regularly enhanced with most recent real data supplied by the meter data providers.This means that until actual meter readings are received, all meters have a generic baseline profile, also known as typified profile [57], for different time periods which can be individualised per meter and time period but can also be defined equally for similar participant types (e.g., all consumption meters from participants with similar features can have the same baseline load profiles and all generation meters with similar characteristics).Forecasts for BESS SOC and energy rate can be conducted using a comparable approach, or alternatively, they can be computed taking into consideration both generation and load factors.The starting SOC for the BESS will be assumed based on historical data.Depending on the experience of individual profiles, future work might encompass aggregating certain user groups into one entity for forecast creation.This could reduce stochastic uncertainty, specifically from residential demand.Trading would be based on aggregated profiles, which would then be split up and reconciled for actual settlement based on historical readings.Users could be aggregated by user type, retailer, or other characteristics such as demand requirements.

A. OPERATION OF FORECASTING SERVICE
In the LEM, whenever a new participant is onboarded, the new participant gets assigned a set of baseline profile curves that are created by the admin.Each baseline profile curve represents a starting point, for how the participant's load consumption, solar PV generation or BESS SOC will be on a particular type of day (e.g., weekday, weekend, season, holidays, etc.) as shown in Figure 6.The platform creates specific meter forecast profiles for different time periods based on the participant's assigned baseline profiles and meter readings.The meter readings for load, solar and inverter readings of the battery SOC with battery energy rate are retrieved daily and applied via the forecasting service to the applicable meter forecast profile for the next trading window (e.g., the next 24 hours).Let w be the index of each LEM participant, where wϵW , W is the set of all LEM participants.Any time duration is indexed by tϵτ , where τ represents the set of all time durations.The forecasted profile curves are calculated as: where baseline cures or previous forecast E FP,tod are updated with real-time meter readings G l,tod based on a defined constant k with a value between 0 and 1, depending on how much weight the user wants to give to the previous forecast values or the real-time meter readings.At the very beginning, E FP,tod is equal to the defined baseline profile.It is important to note that multiple baseline profiles can be established for each meter, covering different timeframes.Consequently, numerous typed forecast profiles can be generated for each meter.Historical meter readings only impact a forecast profile if they fall within the corresponding timeframe; for instance, meter readings from June would solely influence a typical forecast profile applicable to that specific month.
The forecasting service allows the management of profile curves, like importing, adjusting, and displaying curves based on provided input (e.g., the number of people in the household).Each participant is assigned one or more typified curves (e.g., for weekdays, for weekends, etc.).When a profile is requested for the specified time, the appropriate curve is selected, and the profile for the time period is extracted.Initial profile definition and loading should be done from the input source via the baseline profile.The baseline profiles have a default format for loading data but should also be customised/created per project, depending on the format of the input source.

Algorithm 1 Forecasting and Bidding 1:
Step 1: Generate bid quantity using forecast profile 2: Input parameters: t 3: for every user participant for a given t 4: if participant type is a consumer 5: Generate forecast load profile G l (w, t)) from historical baseline profile assigned to the participant 6: Bid quantity is calculated in ( 11) and ( 12) 7: elseif participant type is a prosumer with solar PV 8: Generate forecast load profile G l (w, t)) and solar PV generation profile (G p (w, t)) from historical baseline profile assigned to the participant 9: Bid quantity is calculated in ( 11) and ( 12) 10: elseif participant type is a prosumer with solar PV and BESS 11: Generate forecast load profile (G l (w, t)), Solar PV generation profile (G p (w, t)) and BESS SOC profile (SOC b (w, t) from historical baseline profile assigned to the participant 12: Bid quantity is calculated in (11) and (12) 13: Else 14: Generate forecast EV load (G ec (w, t)) from historical baseline profile assigned to the participant 15: Bid quantity is calculated in (11)  The forecasting and bidding are outlined in Algorithm-1 that will be used by the trading engine for performing matchmaking among energy producers and consumers.A different type of forecast profile is created for each participant using historical data to generate load, generation, and BESS SOC profiles according to the type of participant, as shown from lines 4 to 15. Participants use the UI to place their order price (bid rate in c/kWh) as shown from lines 21 to 24.

B. DISTINCTIVE FEATURES OF LEM
LEM is a P2P energy trading platform that enables participants to buy and sell energy directly with each other without the need for a centralised intermediary.LEM provides a variety of features as shown in Figure 7 to help participants engage in efficient and profitable trading, including: • Dashboard UI: A user-friendly dashboard that provides participants with a comprehensive overview of their energy consumption, generation, and trading activity.
• Meter Service: Creation, updating, and deletion of meter entries and for management of meter details.
• User Service: Responsible for managing users and user data, which includes identifiers, roles, acceptance of terms & conditions and authentication setup.
• Forecast Service: Provide forecasted data to the trading engine for a given time slot.
• Price Service: Collect bid prices from participants and provide them to the trading engine.
• Trading Service: Handle P2P transactions between participants based on input from the price service and forecast service.
• Dispatch Service: Translates the transaction output from the trading service into commands and transfers them to participants.These features work together to create a seamless and efficient P2P energy trading experience for all participants.

IV. BLOCKCHAIN TECHNOLOGY AND INTEGRATION WITH PROPOSED LEM A. BLOCKCHAIN TECHNOLOGY AND P2P TRADING
Blockchain, a contemporary groundbreaking technology rooted in a distributed ledger, has emerged as a compelling innovation for maintaining permanent and tamper-resistant (immutable) records of transactional data.It has garnered significant interest from energy enterprises, national governments, and academic institutions.With the potential to provide transparency, security, and immutability, blockchain technology holds promise, particularly in conjunction with smart contracts, for facilitating novel business solutions.This technology finds a fitting application in the P2P trading arena due to its inherent transparency.Functioning as a digitised, decentralised, and the distributed ledger, 2948 VOLUME 12, 2024 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.blockchain records all transactions within a P2P network.The encrypted nature of data transmitted via blockchain ensures that any data manipulation becomes immediately visible and discernible to all involved parties, thereby enhancing security and accountability.By recording transactions at each stage, blockchain technology guarantees the security, transparency, and dependability of data.Within P2P trading contexts, individuals generate energy through rooftop solar PV systems and subsequently share surplus energy, following self-consumption, with fellow consumers at a mutually agreed-upon price between prosumers and consumers.The application of blockchain facilitates these transactions within the P2P platform and automates the storage of these encrypted transactions.Notably, this occurs without requiring the involvement of intermediaries or energy exchanges.The consequential enhancement in data transparency and reliability, along with the reduction of transaction costs, is a notable advantage attributable to blockchain technology.
Figure 8 demonstrates the interconnected nature of blockchain nodes within the blockchain network and showcases the elements comprising a blockchain node.In a blockchain network, the interconnected computers that store a copy of the record of all historical transactions and have the processing capacity to verify new transactions are referred to as nodes.Each node maintains a complete copy of the blockchain and remains continuously synchronised with other nodes.Additionally, every node possesses its own dedicated processing capacity, often referred to as a virtual machine, which is responsible for executing smart contracts and verifying transactions.In the case of the Ethereum (ETH) blockchain, the virtual machine is known as the Ethereum virtual machine (EVM).Figure 8 illustrates the presence of nodes containing local copies of the blockchain and an EVM.When a user intends to interact with the blockchain, such as by reading or writing data, they need to establish a connection with one of these nodes using web3 interface.
A blockchain transaction is a digital record that signifies the exchange of value or information between participants, and it is stored on the decentralised ledger of the blockchain.Transactions are initiated by participants and smart contracts to document asset transfers and information storage.
Transaction cost in blockchain, also known as transaction fee, is the fee amount paid to validators for processing and confirming a transaction on the network [58].Transaction speed in blockchain refers to the time it takes for a transaction to be confirmed and added to the blockchain [59].Fast transaction speeds are desirable for the timely processing of transactions.
Blockchain technology has undergone significant advancements, progressing through three distinct generations.Gen1 blockchain, like Bitcoin, focused on facilitating digital currency transactions [60].Gen2 blockchains, like Ethereum, introduced smart contracts but encountered scalability challenges.Gen3 blockchains, like Solana, strive to address scalability and energy efficiency concerns while enabling high-speed, low-cost transactions.Among all Gen1, Gen2, Gen3 blockchains, Layer-1 blockchains are the fundamental architecture that underpins the blockchain ecosystem, while layer-2 blockchains are overlay networks that enhance the performance of layer 1 blockchains.Layer 1 blockchains provide security and decentralisation, while layer-2 blockchains address scalability limitations [61].Ethereum's limited throughput of 30 transactions per second, leading to congestion and high fees during peak demand, poses a significant scalability challenge.Layer-2 solutions for Ethereum address this by offloading transaction processing and smart contract execution, enabling faster transactions, reduced congestion, and lower fees [62].These solutions ultimately consolidate transaction data onto the primary blockchain.

B. BLOCKCHAIN INTEGRATION WITH LEM PLATFORM
When a participant wants to access data from a blockchain, the data is obtained from the node's local copy of the blockchain.Reading data from the blockchain does not incur any transaction costs.However, if the user intends to store data on the blockchain, the data undergoes a series of steps.Firstly, the data is transmitted to a connected node, which then verifies its authenticity.Subsequently, the verified data is disseminated to all nodes in the blockchain network for validation.The validation process requires a consensus among many nodes.Once the data is validated by the majority, it is permanently stored in the blockchain, and all nodes synchronise their copies accordingly.When a user wants to write data on the blockchain, there is a transaction cost involved, which reflects the resources consumed during the verification process.When a request is sent to execute the business logic of the smart contract on the blockchain, resources in the form of computational effort are provided by the nodes to execute the business logic and store the data on the blockchain.The smallest unit of measure for the consumption of computational resources in the EVM-based blockchain network is called GAS X GAS .The GAS fee X Fee GAS is the amount of remuneration paid per GAS, and it is determined by the market dynamics.In other words, X Fee GAS is the amount of fees paid by a user to perform any task on the blockchain that requires computational effort.Unit GAS fee X f GAS is denoted in GWEI, which itself is a denomination of ETH -each GWEI is equal to 10 −9 ETH.X Fee GAS (AU $) can be calculated as follows: where X ETH is the Ether price (AU$).if w is registered as participant 9: Step 2: Write data in blockchain 10: Step a: Step c: Store LEM settlement record 17: writeSettlement(t, w) ← Z exp−b (j, t) , Z exp−bb (j, t) , Z sav (j, t) 18: Step 3: Read data from blockchain 19: Step a: Reading bidding data Blockchain can be integrated into the LEM using various methods.One way is to embed all LEM's operational processes, such as payment collection, optimisation, matchmaking, settlement, and billing, into a smart contract [63].In this setup, participants would directly submit their bids to the smart contract.The processes of matchmaking, settlement, and billing would then be executed at specific intervals.This approach represents a highly decentralised implementation of LEM.However, a challenge with this method is the significant transaction cost attributed to the execution of complex operational procedures by network nodes and the storage of all data on the blockchain.
In an alternative approach, the steps involving bid acceptance, optimisation, matchmaking, settlement, and billing are managed through centralised servers.Only the final bid details, trading data, costs, and benefits are stored on the blockchain.Algorithm-2 shows step-by-step information about data storage in blockchain using smart contracts.This method combines the strengths of both centralised and decentralised databases.Important data is stored securely on the blockchain, while complex business logic is handled by a centralised server.All data is also kept on this central server.This approach has been employed in this paper.Specifically chosen data is saved on the blockchain.For each participant and time interval, the blockchain holds the following information: bid data (including energy and price), energy traded within the LEM, costs or revenue from energy transactions, energy traded with the grid, and the benefits of utilising the LEM.

V. P2P TRADING FORMULATION
Assume G l (w, t) is the load demand of each LEM participant during any time duration t ∈ τ .Let W p ⊂ W be the set of LEM participants with solar PV systems.The solar PV generation of each LEM participant that belongs to W p is denoted by G p (w, t).Let W b ⊂ W be the set of LEM participants with BESS.The BESS charged and discharged energy during t are represented by G c (w, t) and G d (w, t), respectively.G c (w, t) is constrained by minimum and maximum BESS charging capacities, G d−min (w) and G d−max (w), respectively.Similarly, G d (w, t) is constrained by minimum and maximum BESS discharging capacities G d−min (w) and G d−max (w), respectively.BESS constraints for in-house operations can be expressed as follows: where SOC b (w, t) and SOC b (w, t − 1) are BESS SOCs during t and t − 1, respectively.These are limited by the minimum and maximum SOCs SOC b−min (w) and SOC b−max (w), respectively.e w c and e w d indicate BESS charging and discharging efficiencies, respectively.
Let W e ⊂ W be the set of LEM participants with EVs, which are in operation for the duration of τ e ⊂ τ .The EV charged and discharged energy during t ∈ τ e are represented by G ec (w, t) and G ed (w, t), respectively.G ec (w, t) 2950 VOLUME 12, 2024 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
is constrained by minimum and maximum EV charging capacities G ec−min (w) and G ec−max (w), respectively.Similarly, G ed (w, t) is constrained by minimum and maximum EV discharging capacities G ed−min (w) and G ed−max (w), respectively.EV constraints can be expressed as follows: where SOC e (w, t) and SOC e (w, t − 1) are EV SOCs during t and t − 1, respectively.These are limited by the minimum and maximum SOCs SOC e−min (w) and SOC e−max (w), respectively.eec w and e ed w indicate EV charging and discharging efficiencies, respectively.The EV operation is also bounded by the desired SOC denoted by SOC e−dis (w) = t∈τ e SOC e (w, t) In this paper, it is assumed that EVs charge from both LEM and the grid, whereas residential BESS can be charged from LEM only.On the other hand, battery energy can also be discharged in the LEM.The energy surplus G sur (w, t) and energy deficiency G def (w, t) of each LEM participant w ∈ W can be calculated as follows: A LEM participant could be either a seller i ∈ I ⊂ W or a buyer j ∈ J ⊂ W depending upon its G sur (w, t) and G def (w, t), where i and j refer to the indices of a seller and a buyer, respectively, and their sets are represented by I and J .Specifically, if G sur (w, t) ̸ = 0 and G def (w, t) = 0, the LEM participant acts as a seller (G sur (w, t) is represented by G sur (i, t)).In contrast, if G def (w, t) ̸ = 0 and G sur (w, t) = 0, the LEM participant plays the role of a buyer (G def (w, t) is represented by G def (j, t)).Both sellers and buyers may not be able to trade their entire energy surplus and energy deficiency in the LEM via P2P trading.Assume G sur−a (i, t) and G def −b (j, t) can be traded via P2P during t.Thus, (G sur (i, t) − G sur−a (i, t))(G def (j, t) − G def −b (j, t)) are required to be sold/bought to/from the grid, symbolised by G sur−aa (i, t) and G def −bb (j, t), respectively, as described in ( 13) and (14).
In BAU, G sur−a (i, t) = 0 = G def −a (j, t) , ∀t ∈ τ , and thus, ( 15) and ( 16) can be rewritten as follows: (13) and ( 14) clearly illustrate that G sur−a (i, t) < G sur−aa (i, t) , ∀t ∈ τ and G def −b (j, t) < G def −bb (j, t) , ∀t ∈ τ .Nonetheless, G sur−a (i, t) and G def −b (j, t) are also constrained by the maximum selling and buying amounts G sur−a m (i, t) and G def −b m (j, t), respectively, set by the LEM admin.Also, the total P2P selling and buying amounts during t, denoted by i∈I G sur−a (i, t) and j∈J G def −b (j, t) should be equal.These are depicted in the following equations: Let m g and m f be the grid buying and selling prices respectively.For P2P trading, LEM participants seek to trade between m f and m g to attain maximum monetary gains.One LEM participant can trade with multiple peers in one time duration at different prices.Assume m p w,t is the average P2P trading price of each LEM participant w, such that: where m p w,t ∈ [m a i,t , m b j,t ] Revenue in the LEM and as per BAU, denoted by Z ear−a (iw, t) and Z ear−aa (i, t), respectively can be calculated as: where the difference between Z ear−a (i, t) and Z ear−aa (j, t) is termed as the profit in the LEM signified by Z pro (i, t), such that: Costs in the LEM and as per BAU, denoted by Z exp−b (j, t) and Z exp−bb (j, t), respectively, can be calculated as: where n a j,t includes other LEM costs, such as network fee, LEM platform cost, energy retailer margin, and taxes.where the difference between Z exp−b (j, t) and Z exp−bb (j, t) is termed as the saving in the LEM signified by Z sav (j, t), such that: The objective of the proposed LEM is to maximize Z pro (i, t) and Z sav (j, t) for each LEM seller i and buyer j follows: The sequential actions in the trading engine are listed in Algorithm-3 that allows P2P trading in LEM.Firstly, the trading engine does P2P matchmaking with consumers and prosumers.P2P energy quantity and P2P energy rate are calculated for each successful P2P trade.Secondly, if there exists unfulfilled load and/or generation then participants will The steps involved in billing and settlement in LEM are shown in Algorithm-4.P2P trade data recorded from the trading engine are given as inputs to calculate the LEM cost of energy for each participant.

A. CALCULATION OF CO 2 EMISSION, SELF-SUFFICIENCY, AND SELF-CONSUMPTION
The total load demand of the LEM is represented by G tot and calculated as: The total grid imports in BAU and in LEM are represented by G Imp BAU and G Imp LEM , can be calculated as: The total grid exports in BAU and in LEM are represented by G Exp BAU and G Exp LEM , respectively, and can be calculated as follows: 2952 VOLUME 12, 2024 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.The self-sufficiency in LEM and BAU, denoted by S Suf BAU and G Suf LEM , respectively, can be calculated as follows: Besides, self-sufficiency in LEM and BAU, denoted by S Con BAU and S Con LEM , respectively, can be calculated as follows: The CO 2 emission resulted from using electricity from the grid can be calculated for BAU and LEM, denoted by E Cr BAU and E Cr LEM , respectively, as followed [64]: Where EF represents the grid emission factor, which is the emissions rate of the energy available in the grid (EF= 0.51 kg CO 2 -e/kWh) [65].So, reduction in CO 2 emission E Cr RN by the use of LEM can be calculated as:

VI. PROPOSED BLOCKCHAIN-BASED MODEL AND INPUT PARAMETERS
The proposed architecture of the local LEM includes twenty residential participants, which comprise eight consumers, eight prosumers equipped with solar PV, three prosumers with solar PV and BESS, and one EV.The participants are connected to four feeders under a single substation as shown in Figure 1.Each user's solar PV system has a capacity of 6 kWp, while the installed BESS size is 12 kWh with a 3.3 kW charger.The EV's battery size is 30.2 kWh, and the charge rate is between 3 kW and 7.2 kW [63].Within the context of the case study, actual data was extracted from real-world sources (see [66] for details).The data utilised from the given dataset was selected at random and consists of load consumption and solar PV generation data.The final dataset encompasses 19 households located in New South Wales (NSW) over a single day during the typical summer season (December to February).The illustrative annual average profiles depicted in Figure 9 offer insight into the trends  observed.It becomes evident that load consumption reaches its peak during the evening hours, while the generation of power through solar PV panels is most prolific during the afternoon time frame.

A. LEM INPUT PARAMETERS
One of the input parameters that the LEM trading engine receives is participants' energy bids.Energy buying and selling through LEM involves placing energy bids through the participant's UI screen.In P2P trading, the trade happens in a retrospective manner where price is pre-defined for any volume of excess energy generated by the prosumer (seller) assets.Buying price is also pre-defined by the consumer (buyer), regardless of the volume of energy that is to be consumed through P2P trade.Prices are set with a minimum and maximum payment willingness cap and the trading engine settles the transaction.If a participant acts as a seller, they establish a bid price higher than the FiT rate.Conversely, if the participant acts as a buyer, the bid rate is set below the ToU energy rate, as depicted in Figure 10.In Figure 10 (a), the bid price of a prosumer with solar PV is shown for a day.
When the net energy is negative, indicating energy demand, the prosumer with solar PV becomes a buyer and submits a bid just below the ToU energy rate.Alternatively, when the net energy is positive, it represents an energy surplus, the prosumer with solar PV becomes a seller and submits a bid slightly above the FiT rate.Another set of input parameters is received from a forecasting service that provides forecasted profiles of each type of participant to perform match making.The trading engine carries out tasks such as energy trading, billing, and settlement using these forecasted profiles and the bid prices provided by the participants.Once actual data from the smart meter is received, the baseline profiles are used and transformed into a forecast profile, which will be utilised by the LEM trading platform.The EV SOC status, along with the charging cycle start and end times, were considered within the time frame of 08:00 to 18:00.Figure 11 (a) shows the load consumption baseline, actual, and forecasted profiles.Consumption is maximum in the evening around 18:00 hours and minimum around midnight at 00:00 hours.Figure 11 (b) illustrates the baseline, actual and forecasted profiles of solar PV generation, and its value is at its maximum in the afternoon time around 13:00 hours.Figure 11 (c) depicts the BESS SOC baseline, actual, and forecasted profiles.The BESSs are fully charged around 15:00 hours and start discharging after 16:00 hours to trade within the LEM. Figure 11 (d) depicts the EV baseline, actual, and forecasted profiles.The actual charging started and ended slightly later than predicted by the forecast profile.
In typified forecasting methods, classifiers such as mean absolute percentage error (MAPE) and root mean square percentage error (RMSPE) play a vital role in assessing prediction accuracy for parameters like load, generation, BESS SOC, and EV load.MAPE calculates the average percentage difference between predicted and actual values, with lower values indicating higher accuracy.RMSPE, a variant of Root Mean Square Error adapted for percentage errors, penalises larger errors more heavily, providing insights into overall error consistency.Table 3 provides a summary of the forecasting accuracy matrices for key parameters-load, generation, BESS SOC, and EV load.In the specific study, lower MAPE and RMSPE values for EV load suggest precise predictions, while comparatively higher values for load may signal areas for improvement in forecasting overall energy demand.These classifiers serve as quantitative benchmarks, aiding in the refinement and optimisation of forecasting models within the realm of local energy markets.

BLOCKCHAIN SETTINGS AND SMART CONTRACT DETAILS
For the blockchain integration, the local Ethereum blockchain is set up using GanacheUI v2.7.1 which is a development tool for creating Ethereum test networks.This local blockchain environment allows one to experiment with blockchain technology without interacting with the actual Ethereum mainnet.In this paper, an EVM-compatible LEM smart contact is written in the Solidity programming language using the REMIX IDE.A private Ethereum blockchain is created using Ganache CLI v6.12.2, and to interact with the Ethereum blockchain, the web3.pylibrary is used, which is a Python library that allows communication with Ethereum nodes.The web3.py provides a convenient interface for sending transactions, querying data, and interacting with smart contracts on the blockchain.web3.pylibrary is used as an interface to test LEM smart contracts.The GAS amount consumed for each transaction is calculated, which is used to estimate the transaction fee cost that would occur when LEM smart contracts are implemented in EVM-compatible public Gen2 blockchains such as Ethereum (layer-1) and the Polygon (layer-2) network [67].The process of storing and retrieving energy data records in blockchain is outlined in Algorithm-2.The following features summarise the primary functionalities of the LEM smart contract: • User Registration: New users are registered with the registerUser function.
• Energy Bidding: User energy bid data for given time interval is recorded using biddingDataInput function.
• Energy Trading: User P2P trade records are recorded using writeTradeRecord function.
• Settlements: User settlement data can be recorded with writeSettlement function.
Reading Data: User can retrieve information related to bids, trades, and settlements using the readBidData, readTradeRecrd, and readSettlement functions.These functions ensure that the user is registered before returning data.
The LEM smart contract operates as a decentralised, secure ledger for managing energy trading data.While P2P matchmaking between buyers and sellers occurs off-chain for efficiency, the blockchain is utilised to register users, record, and manage transactions, bids, and settlements data.This approach leverages the blockchain's immutability and transparency to ensure data integrity while optimising transaction costs through off-chain operations.The detailed steps 2954 VOLUME 12, 2024 Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.for blockchain implementation using Ganache, REMIX, and web3.py are given below: • Configure Ganache and Connect to REMIX: Start Ganache UI and create a new workspace.Obtain the RPC URL provided by Ganache UI and set the environment to ''Web3 Provider'' in REMIX and input the Ganache RPC URL for connection.
• Develop and Deploy Smart Contract in REMIX: Write Solidity smart contract code in the REMIX IDE, compile it, and deploy the smart contract to the Ganache network through REMIX.
• Write Python Script Using web3.py:Install the web3.pylibrary and import web3.py in a Python script.Connect to Ganache using the Ganache RPC URL in a Python script.Import the ABI and address of the deployed smart contract.
• Interact with Smart Contract: Use web3.py to create transactions to interact with the smart contract's functions.Call functions, send transactions, and query the contract's state within Python script.
• Execute Python Script for Testing: Run Python script to simulate transactions and interactions with the smart contract.Monitor the results in both the Ganache UI and Python console.

VII. RESULTS AND ANALYSIS
This paper involves the simulation of the proposed LEM models.The simulations encompass the incorporation of all stipulated functional limitations outlined in Section II and III, where market rules are strategically defined.These rules are formulated to achieve primary objectives, including the reduction of participants' energy costs, the preservation or enhancement of margins for distribution utilities and energy retailers, and the mitigation of power grid congestion through the integration of BESSs.Additionally, the outcomes of the LEM simulations are subject to analysis, drawing comparisons with the BAU model.Moreover, a succinct comparative assessment is conducted among the investigated models, aiming to identify the most fitting option within today's energy market landscape.

A. ANALYSE LEM ENERGY TRADING
The energy trading within the LEM for each type of participants for a trading day is shown in Figure 12.In Figure 12 (a), the energy behaviour of prosumers with solar PV and BESS is presented, and results show that in the morning time, it buys energy from grid to fulfill its load.When the solar PV starts to generate electricity, first it is used to fulfill its own load and then charge its own BESS.If there is excess energy left, it will sell to peers and remaining energy is sold to grid.Throughout the daytime, generated energy from solar PV fulfils its own load and charges the BESS.Additionally, during peak tariff periods, the BESS can discharge energy to peers, generating economic advantages, as shown at 17:00 and 18:00 hours.It should be noted from Table 2 that peak ToU starts from 16:00 to 21:00.At 18:00, a prosumer with a solar PV and a BESS has a load of 1.62 kWh.BESS is both self-discharging (1.62 kWh) and selling to peers the grid (1 kWh).At the evening time, its load is fulfilled fully by its own BESS.Figure 12 (b) and Figure 12 (c) show the energy usage patterns of EV and consumers, respectively.Both EVs and consumers utilise a combination of the LEM and the grid to fulfill their energy needs.Figure 12 (d) outlines the energy dynamics of prosumers with solar PV.These prosumers attempt to sell their excess generated energy, after self-consumption within the LEM, to peers.While any surplus energy beyond P2P trade in LEM is sold to the grid at the FiT rate, as can be seen from 8:00 to 16:00.Similarly, when there is energy demand, they aim to buy energy from peers in the LEM first and then, if needed, from the grid.In  in the afternoon time.In the LEM, P2P trading happens from morning 08:00 hours to evening 19:00 hours when available generated energy is more than load demand.Mainly, P2P trading is happening due to the excess solar PV generation and discharging of BESS.The maximum P2P energy trade of 7.56 kWh is happening at 14:00.Prosumers with solar PV and BESS use the excess energy generated after load consumption to self-charge BESS (as shown by the positive part of orange graph in Figure 13).Additionally, the BESS discharges to offset their own load requirements in the morning, evening, and night hours (as shown by the negative part of the orange graph in Figure 13).EV's energy trading with P2P and grid trading is shown, where priority is given to LEM trading before resorting to energy from the grid.Figure 13 illustrates that during the 10:00 hours, the EV is charged at the full rate of 5 kWh, where 1.63 kWh is charged from peers and the remaining 3.37 kWh is charged from the grid.

B. LEM ENERGY COST AND REVENUE
Figure 14 illustrates the cost/revenue linked to each type of participant when engaging in the LEM. Figure 14 (a) shows the prosumer with solar PV and BESS makes most of the revenue by discharging energy in the evening peak time due to the high cost of energy.BESS can also be charged from peers at a low tariff during solar hours, be stored, and sold during evening time at a peak tariff, as we can see at 8:00 (buying).BESS discharging to peers is limited to SOC of 50% so that BESS will have energy left for self-discharge during night and next morning time.The cost of EV charging in LEM is lower than in BAU, where EVs buy all their energy from the grid.Figure 14 (c) shows the consumer cost of buying energy, which is a mix of energy from peers and energy from grid Prosumers' cost and revenue from energy trading is shown in Figure 14 (d).The graph shows that prosumers are making revenue by trading excess solar energy to peers and the grid and buy energy from peers' BESS and the grid in evening time.It is clearly shown that due to participation in LEM, overall revenue has been increased and costs have been decreased.
Upon engagement in the LEM, participants witness changes in their cumulative electricity costs relative to a preexisting BAU model.In Figure 15, we observe the monthly average electricity bill reduction for distinct categories of participants.Specifically, EV owners, general consumers, prosumers equipped with solar PV installations, and prosumers with solar PV and BESS have a reduction of 9.2%, 3.6%, 29.5%, and 45%, respectively, and the average reduction of all participants is 21.6%.
The forecasting service generates an energy profile for each participant.Through a trading agent each participant places their desired bid prices for P2P energy trading.The trading engine performs optimisation and matchmaking processes in which P2P energy trading is done for each participant and for every time interval.A record of P2P transactions for a prosumer with solar PV for a day is shown in Table-4.Prosumers can act as buyers and sellers at different times of the day, as can be seen at different times of the day.At 07:00, when there is no solar PV generation, P-1 is an electricity buyer, and buys electricity from the grid.From 8:00 to 16:00, the solar PV generation of P-1 exceeds its load, so it sells its excess energy to peers in LEM at an average bid price between buyer and seller.At 13:00, P-1 is selling excess generated energy to three different buyers at three different energy rates.Since the bid prices of participants are different, even if there is a single seller and multiple buyers, the final trading rate will be different for all participants.At 17:00, P-1 acts as a buyer and buys energy from two BESSs.It is financially beneficial for both P-1 and the BESSs to trade energy in LEM.

C. LEM REDUCE GRID CONGESTION ISSUE AND BENEFIT THE NETWORK STAKEHOLDERS 1) GRID IMPORT AND EXPORT
Figure 16 illustrates the impact of the proposed LEM model on the power grid's import and export profiles.The LEM model reduces the power grid export by 4% when compared to BAU without EV.This is because EV charges during the daytime when there is excess solar PV generation, thus reduces peak export by 4%.The LEM model with EV reduces grid export by 16% when compared with LEM without.This reduction is because BESSs and EVs are charged by utilising the surplus energy available in LEM during the shoulder time.The LEM model with and without EV reduces power import from the grid at peak times by 4% as compared to both BAU without EV.This decrease in power grid import is accomplished by discharging BESSs with the aid of P2P trading during peak demand periods.Import of power from the grid occurs during evening hours, when there is no EV load, resulting in the power import from the grid remaining consistent with or without EV involvement.In a comprehensive analysis, the adoption of the LEM model instigates a reduction in both power grid exports and imports.

2) NETWORK MARGINS
A comparison of energy retailers' margins is illustrated in Figure 17, encompassing the BAU approach and the proposed LEM model.Notably, as shown in Figure 17 (a), the income margin of energy retailers derived from the trading consortium experiences a 3.35% augmentation correlated with the volume of P2P transactions.This upswing can be attributed to the involvement of BESSs, which engage in charging and discharging operations with neighbouring participants.The daily income margin of the distribution utility experienced a 1.74% increase, as shown in Figure 17 (b) within the framework of the proposed LEM model.This contrast is depicted in Figure 17 when compared to the BAU model.The adoption of the proposed LEM model has notably enabled the distribution utility to mitigate the adverse effects stemming from unregulated local DER penetrations.This achievement is realised through the facilitation of P2P trading.Additionally, the LEM model can contribute to the reduction of operational and capital expenditures of the power grid.
3) IMPROVED SELF-CONSUMPTION AND SELF-SUFFICIENCY Fig. 18 shows the self-sufficiency of the community in the LEM model.The LEM model achieves 2.2% increase in self-sufficiency when compared to BAU, allowing communities to rely more on their own energy resources.Simultaneously, the LEM model contributes to a significant 4.6 % increase in self-consumption, encouraging individuals   and entities to consume a larger portion of the energy they generate.

4) REDUCTION IN CO 2 EMMISSION
The integration of the LEM model carries significant environmental significance, translating to an annual decrease of 984 kg CO 2 equivalents in carbon emissions.Figure 19 shows that the proposed LEM model reduces 4% of the CO 2 emissions that can support to achieve green energy goals at distribution level.LEM model.Given the substantial number of transactions, totaling 720, for both consumers and prosumers utilising LEM, the associated blockchain usage cost is higher, approximately AU$19.11.In the case of prosumers equipped with BESSs, the transaction fee is lower at AU$9.55.This is attributed to the BESS's ability to self-charge and discharge during specific periods of the day, resulting in a smaller number of transactions, specifically 360, recorded in the blockchain.Similarly, EVs contribute only 142 transactions when being charged, resulting in the lowest transaction fee of AU$3.77 compared to other participants.

D. GEN2 BLOCKCHAINS IMPLEMENTAION COST AND TIME
The transaction speed for layer-1 (Ethereum) blockchain is 30 transactions per second, and for layer-2 (Polygon) blockchain it is 7,000 transactions per second [68].Table 6 compares transaction time and fees for layer-1 and layer-2 blockchains during the non-congestion period of the proposed LEM architecture.a maximum processing capacity of 30 transactions per second for layer-1 blockchain, the total number of transactions for consumers is 720.Storing all transaction data necessitates approximately 24 seconds, resulting in a transaction fee of approximately AU$6,206.11.In contrast, the transaction fee for layer-2 blockchain for the same data is significantly lower at AU$19.15.During moderate congestion periods, the transaction time for layer-1 is 14 seconds, while layer-2 completes the LEM transactions in only 2.1 seconds.Overall, Table 6 demonstrates that the implementation time and cost of layer-2 blockchain are superior to those of layer-1 blockchain.

E. COMPARISON WITH OTHER WORK
Figure 20 depicts a comparative analysis between the simulated outcomes of the proposed LEM and similar existing studies.In Figure 20 (a), the benefits achieved by participants when compared between the proposed LEM model and [69] is presented.Specifically, the average bill reductions for consumers stand at 8.7%, whereas for prosumers, it amounts to 13.2%.Within the proposed LEM model, the average bill reductions for consumers and prosumers are recorded at 6.5% and 37.5%, respectively.Notably, in the proposed LEM, participants, especially prosumers with BESS, demonstrate greater benefits.In Figure 20 (b), a comparison of the peak grid export of the proposed LEM against [70] is presented.While [70] attains a peak grid export reduction of 19.5%, the proposed LEM model achieves a very similar reduction of 20.0% in peak grid export.Subsequently, Figure 20 (c) illustrates the comparison of self-sufficiency between the proposed LEM and [71].The proposed LEM would achieve a total self-sufficiency of 48.7%, while the increase in self-consumption achieved in scenario-4 of [71] is 43.0%. Figure 20 (d) showcases a comparison regarding the reduction in transaction costs upon integrating blockchain in LEM.Both studies explore layer-1 and layer-2 blockchain solutions, examining the associated transaction costs and reductions achieved.The proposed LEM model demonstrates a remarkable transaction cost reduction of up to 99%, surpassing [72] which achieved a reduction of up to 98%.

F. DISCUSSION AND LIMITATIONS
The incorporation of blockchain technology into LEM has demonstrated significant potential.The introduction of Ethereum-based smart contracts has facilitated the development of decentralised P2P energy trading within the LEM framework.However, as discussed in Subsection VII-D, Ethereum, being a Gen2 layer-1 blockchain, faces challenges such as network congestion and high transaction costs, particularly impacting its applicability in applications like LEM that require high throughput.To address such layer-1 limitations, Ethereum-based layer-2 blockchains, such as Polygon, have been introduced.This layer-2 solution aims to enhance the scalability and efficiency of layer-1 blockchain networks by processing a substantial portion of transactions off-chain or through alternative chains.While this layer-2 solution improves overall transaction times and reduces energy trading costs, it still poses financial challenges for energy participants and represents an additional expense for network operators.Additionally, layer-2 blockchains introduce additional concerns around cybersecurity, and unnecessarily increases the system complexity.Overall, both Gen2 blockchains are not optimal for LEM because of the limitations related to throughput, transaction costs, complexity and environmental impact.
Gen3 blockchains, like Solana or Powerledger blockchain (PLBC), could be a better option because they support high throughput, have minimal and predictable gas fees, require low energy consumption and has lesser cyber security issues.

VIII. CONCLUSION
This paper has presented an implementation of a LEM using blockchain technology for P2P trading among three types of participants: consumers, prosumers with solar PV systems, and prosumers with solar PV systems and BESSs.The LEM platform has been designed to ensure secure and transparent trading between the participants, reducing the need for intermediaries, such as retailers, and enabling them to exchange energy directly.The LEM platform involves several crucial steps, including creating forecasting profiles, bid placement, matchmaking, and trading execution, all of which are executed securely using blockchain technology.The forecasting solution creates typified forecasting profiles of load consumption, solar generation, and battery state of charge, which are adapted over time through meter readings and sent to the trading engine service for further processing.Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
The participants place their pricing bids through a trading agent service to the LEM, and the trading engine collects profile data from the forecasting solution and bid prices through the trading engine service, performing matchmaking in a forward-facing market.The output of the trading engine includes dispatch signals of energy values sent to the prosumers with BESS to perform real-time dispatch.The trading engine also stores accepted and past bidding data as well as energy values of P2P trades for each participant in the blockchain, and the stored data is retrieved and displayed on the LEM user interface screens of participants and the admin using their blockchain account addresses at any time of trading.The use of blockchain technology ensures secure data storage and quick data retrieval when participants want to view information on their user interface screens.
This research presents a comprehensive analysis of the proposed LEM models, underscoring their potential for reshaping the energy landscape.The simulations reveal favourable energy trading patterns, cost-revenue enhancements, grid congestion alleviation, and significant reductions in CO 2 emissions to align with environmental sustainability goals.While acknowledging the nuanced trade-offs, particularly concerning blockchain implementation costs, the overall findings emphasise LEM's ability to drive sustainable energy practices, boost self-sufficiency, and benefit both participants and the environment.The results of the study demonstrate that a P2P trading-based LEM has a significant impact and increases benefits for all the participants, retailers, and network operators while reducing DERs penetration in the network and decreasing grid energy import and export, resulting in reduced operational and capital expenditure.The implementation of blockchain technology ensures secure data storage and quicker data retrieval, increasing trust among the participants and reducing the risk of fraudulent activities.Finally, the paper also hinted to some costs and technical limitations of using Gen 2 blockchain in LEM.

IX. FUTURE WORKS
Future research directions could focus on enhancing the LEM platform with more advanced features, such as dynamic pricing and demand response, to further increase the benefits for all the participants involved in the energy trading process.The proposed LEM platform can also serve as a framework for developing similar platforms in other industries where P2P trading can be beneficial.Future work will focus on the real-time operations and lessons learned from the technology adoption of the P2P trading-capable LEM.This form of LEM incorporates cutting-edge methodologies such as blockchain technology, and Artificial Intelligence.Another important future work would include the exploration of a further advanced Gen3 PLBC blockchain in LEM and P2P trading.Such a blockchain would be a fusion of high throughput, coupled with frugal energy consumption, and very low gas fee to demonstrate its fit-for-use in the energy applications.

FIGURE 1 .
FIGURE 1.A Physical layout of local energy market to show P2P trading between Consumers, Prosumers, Prosumers with BESS, and EV.

FIGURE 2 .
FIGURE 2. LEM development layouts with proposed services.

FIGURE 3 .
FIGURE 3. LEM workflow for LEM trading engine and data storage.

FIGURE 4 .
FIGURE 4. Three functional layers of LEM framework.

FIGURE 5 .
FIGURE 5. LEM UIs for participants and admin users.
rates for BAU established by a retailer, with the assumption that two participants (one prosumer and one consumer) intend to engage in P2P trading within the LEM.Despite incurring a certain amount of LEM platform cost, P2P trading enables participants to obtain varied energy prices compared to BAU through purchasing from other participants in the LEM at different time periods.Additionally, LEM affords the prosumer the opportunity to sell energy at a rate different from the FiT rate.The daily supply charge and underlying fees such as network fees, renewable energy target (RET), and energy

FIGURE 9 .
FIGURE 9. Average load and generation profile.

FIGURE 10 .
FIGURE 10.Participant's bid price for (a) a prosumer with solar PV, and (b) total number of participants.
Figure 10 (b) illustrates the bid prices of all 20 participants over the course of a day.

FIGURE 12 .
FIGURE 12. Energy trading profiles of participants (a) Prosumer with solar PV and BESS (b) EV (c) Consumer, and (d) Prosumer with solar PV.

FIGURE 14 .
FIGURE 14.Energy cost/revenue for each type of participant.(a)Prosumer with PV and BESS (b)EV (c) Consumer (d) Prosumer with PV.

Figure 13 ,
BESS, EV, and P2P energy flows are compared with respect to load and solar PV generation.It is shown that load profile peak value is 20.6 kW in the evening time and solar PV generation has a maximum value of 15.25 kW

FIGURE 15 .
FIGURE 15.Participants' average monthly electricity cost comparison between the BAU model and proposed LEM model.

FIGURE 17 .
FIGURE 17. Retailer's Margin comparison between the BAU model and proposed LEM model.

FIGURE 19 .
FIGURE 19.Annual CO 2 emission in BaU and LEM model.

FIGURE 20 .
FIGURE 20.Comparison of proposed LEM with different studies.

APPENDIX
Appendix-I, list of symbols and abbreviations.

TABLE 1 .
Summary of related works and proposed work.

Table 2 displays the electricity
Energy quantity and rate declared by the seller i, ∀i ∈ I G def (j, t), m d j,t ← Energy quantity and rate declared by the buyer j, ∀j ∈ J 2: Sort {G sur (i, t)} in ascending order, ∀t ∈ τ 3: Sort {G def (j, t)} in ascending order, ∀t ∈ τ 4: P t = G sur i , C t = G )Algorithm 3 Trading Engine 1: Input parameters: t ← Time, ∀t ∈ τ G sur (i, t) , m d i,t ←

every P2P trading record for a given t
Algorithm 4 Settlement and Billing 1: Step 1: Settlement 2: Input parameters: t, [i, j, G sur−a (i, t) , m p w,t ], m f , m g 3: For

TABLE 3 .
Forecasting accuracy metrics for LEM MAPE and RMSPE metrics.

.
Power export and import comparison between BAU model and LEM model with proposed P2P trading.

Table - 5
presents the economic and transaction time analysis for employing a layer-2 blockchain in the proposed Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.

TABLE 7 .
Technical terms and abbreviations.