Next Article in Journal
A Systematic Review of Hierarchical Control Frameworks in Resilient Microgrids: South Africa Focus
Previous Article in Journal
The Carbon Cost of Intelligence: A Domain-Specific Framework for Measuring AI Energy and Emissions
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Blockchain-Integrated Stackelberg Model for Real-Time Price Regulation and Demand-Side Optimization in Microgrids

1
Department of Electrical & Computer Engineering, Nazarbayev University, Astana 010000, Kazakhstan
2
Department of Electrical & Electronics Engineering, Birla Institute of Technology, Ranchi 835215, India
3
Department of Electrical Engineering, Malaviya National Institute of Technology, Jaipur 302017, India
4
Department of Electrical & Electronics Engineering, School of Physics, Engineering, and Computer Science, University of Hertfordshire, Hatfield AL10 9AB, UK
5
Department of Electrical Engineering, Punjab Engineering College, Chandigarh 160012, India
*
Author to whom correspondence should be addressed.
Energies 2026, 19(3), 643; https://doi.org/10.3390/en19030643
Submission received: 5 December 2025 / Revised: 17 January 2026 / Accepted: 18 January 2026 / Published: 26 January 2026
(This article belongs to the Section A1: Smart Grids and Microgrids)

Abstract

Renewable-driven microgrids require transparent and adaptive coordination mechanisms to manage variability in distributed generation and flexible demand. Conventional pricing schemes and centralized demand-side programs are often insufficient to regulate real-time imbalances, leading to inefficient renewable utilization and limited prosumer participation. This work proposes a blockchain-integrated Stackelberg pricing model that combines real-time price regulation, optimal demand-side management, and peer-to-peer energy exchange within a unified operational framework. The Microgrid Energy Management System (MEMS) acts as the Stackelberg leader, setting hourly prices and demand response incentives, while prosumers and consumers respond through optimal export and load-shifting decisions derived from quadratic cost models. A distributed supply–demand balancing algorithm iteratively updates prices to reach the Stackelberg equilibrium, ensuring system-level feasibility. To enable trust and tamper-proof execution, smart-contract architecture is deployed on the Polygon Proof-of-Stake network, supporting participant registration, day-ahead commitments, real-time measurement logging, demand-response validation, and automated settlement with negligible transaction fees. Experimental evaluation using real-world demand and PV profiles shows improved peak-load reduction, higher renewable utilization, and increased user participation. Results demonstrate that the proposed framework enhances operational reliability while enabling transparent and verifiable microgrid energy transactions.

1. Introduction

1.1. Motivation

The decentralization of modern power systems is reshaping electricity production, trading, and consumption across distribution networks. Microgrids equipped with rooftop photovoltaic systems, small wind turbines, electric vehicles, and battery storage units are increasingly viewed as essential components of future energy communities. However, their operation continues to rely on conventional pricing structures and centralized control mechanisms that were not designed for systems dominated by prosumers. As renewable penetration increases, the variability of generation combined with inflexible demand often results in local supply–demand imbalances, thereby increasing the dependence on the main grid. Although demand-side management programs offer potential solutions, many existing schemes rely on fixed tariffs or manual procedures that offer limited responsiveness and insufficient transparency, reducing user engagement and limiting real-time adaptability. Moreover, peer-to-peer energy exchanges among prosumers introduce challenges related to fairness, verification of delivered energy, and trust in financial settlements.
Blockchain technology has emerged as a promising solution to address these concerns by offering transparent, tamper-resistant, and automated transaction handling. However, many current blockchain-based microgrid implementations remain limited to tokenization or basic peer-to-peer trading and do not incorporate real-time price formation, optimal load scheduling, or incentive-compatible demand response. In parallel, game-theoretic approaches such as Stackelberg models provide a strong theoretical foundation for dynamic pricing and strategic interactions among microgrid participants. However, these models are often confined to simulation studies and do not extend to a practical, enforceable operational layer capable of integrating real-time measurements and verifiable settlement. These limitations highlight the need for a unified framework that combines a mathematically rigorous pricing mechanism with a transparent and decentralized execution platform. Microgrids require an architecture that can regulate prices based on operating conditions, coordinate prosumer and consumer decisions, reward flexibility, and ensure all transactions are verified securely. By combining Stackelberg-based price regulation with blockchain-driven automation, this study aims to establish an integrated system in which price signals, load adjustments, prosumer exports, and financial settlements operate in a cohesive manner. Such an approach enhances the utilization of renewable energy, improves operational reliability, and supports fully transparent, low-cost participation in local energy markets.

1.2. Literature Review

Microgrid systems have emerged as a strategic solution due to their ability to support the integration of renewable energy sources, offer lower energy costs, enhance system resilience, and improve the operational reliability of localized energy distribution networks [1,2]. The growing need for decentralized energy management has underscored the importance of localized electricity markets, particularly in low and medium-voltage distribution networks. Such platforms empower stakeholders ranging from prosumers equipped with distributed generation units to large-scale RES producers and flexible demand-side participants to engage in market-driven energy transactions. Demand Response (DR) programs, which incentivize users to shift or curtail electricity consumption during peak periods, enable better load balancing and enhance market competitiveness [3]. Microgrids, therefore, serve as an ideal platform to meet localized demand sustainably through RES while reducing stress on centralized utility infrastructure. However, challenges persist, especially with the inherent intermittency of RES due to seasonal and weather variability, which can compromise standalone system performance [4]. To address these reliability concerns, Demand Side Management (DSM) plays a crucial role by aligning consumption with generation availability [5]. Given the variability in user load profiles, microgrids benefit from flexible load control mechanisms, such as load shedding and adaptive demand management. Game theory offers a powerful analytical framework for optimizing energy scheduling and incentivizing coordinated behavior among distributed participants in a decentralized system. For such active distribution networks (ADN) to function effectively, existing low and medium-voltage infrastructure must be modernized to support bidirectional energy flows and dynamic market operations. DR mechanisms, in this context, enable microgrid operators to rapidly balance supply and demand during contingencies, while also allowing consumers and prosumers to engage in energy markets for economic and operational gains. These programs contribute to reduced peak-to-average ratios (PAR), improved DSM, and cost optimization by encouraging consumption adjustments in response to real-time pricing and incentive signals [6,7,8,9].
To ensure the effective operation and success of microgrids, several core challenges must be addressed. These include integrating local market structures within low- and medium-voltage (LV/MV) distribution systems, establishing seamless coordination among distribution system operators (DSOs), and creating user-friendly interfaces that encourage public involvement and engagement. Among emerging technologies, blockchain has gained significant traction due to its potential to enhance demand-side energy management and facilitate secure peer-to-peer (P2P) energy trading within microgrids. By using decentralized ledgers, blockchain enables energy providers and consumers to transact in real-time. With Ethereum-based smart contracts, transactions become secure, automated, and tamper-proof. This study particularly emphasizes reducing latency in P2P transactions by optimizing blockchain parameters such as block size and the number of validating nodes. The decision-making process within the blockchain network is managed via programmable smart contracts [10,11]. A network of smart meters, IoT sensors, and communication devices, integrated through Information and Communication Technologies (ICTs), creates a responsive, user-friendly platform for implementing Demand Side Management (DSM). The proposed system utilizes Ethereum smart contracts for demand response (DR) applications, ensuring secure, real-time supervision of microgrid operations. A typical microgrid architecture encompasses renewable energy sources (RES), critical and non-critical consumer loads, DSOs, smart metering infrastructure, Human-Machine Interfaces (HMI), protective devices (relays, breakers), home automation systems, communication backbones, and IoT components. Proper synchronization among these subsystems ensures robust monitoring, control, and energy flow management across the microgrid. However, conventional cybersecurity methods fall short in securing these complex cyber-physical systems. As a result, blockchain has emerged as a powerful tool to reinforce security. Since 2015, blockchain has seen growing deployment in the energy sector for various applications ranging from decentralized trading and DER management to enhancing grid security and operational transparency [12]. Extensive studies have examined the integration of distributed resources, such as RES, batteries, and electric vehicles, into utility grids. Blockchain helps overcome many of the operational and coordination challenges faced by microgrids, particularly in optimizing load control and demand management [13,14]. Additionally, blockchain-based frameworks have been developed for DER scheduling and trading automation [15]. One notable contribution by Munsing et al. involves a decentralized Optimal Power Flow (OPF) model that leverages blockchain for DER scheduling in microgrids [16]. The implementation of blockchain has demonstrated measurable benefits, including flattening the load curve, reducing the peak-to-average ratio (PAR), and resolving supply-demand mismatches. Its decentralized control logic facilitates joint decision-making between system operators and market participants. By embedding a cyber layer into smart grid elements through blockchain, the overall operational efficiency and reliability are improved [17]. Blockchain is increasingly viewed as a key technology for enabling transparent, fraud-resistant peer-to-peer (P2P) energy markets and enhancing cyber-physical resilience, given the growing significance of decentralized power systems [18,19,20].
The comparative review presented in Table 1 indicates that existing studies typically address isolated aspects of microgrid energy management, such as Stackelberg-based pricing, blockchain-enabled transaction security, or demand response mechanisms, but rarely integrate these elements into a unified operational framework. Earlier works employing Stackelberg game formulations mainly focus on price formation or demand response modeling, yet they lack blockchain-based enforcement or are limited to one-directional utility-to-user interactions. Conversely, several blockchain-oriented studies emphasize peer-to-peer energy trading and decentralized security, but often rely on proof-of-work public blockchains, adopt auction-based clearing mechanisms instead of formal game-theoretic pricing, or omit real-time demand response incentives and penalty enforcement. Moreover, many existing approaches remain simulation-oriented and do not demonstrate full on-chain deployment or practical execution workflows. Importantly, only a limited number of studies consider the joint integration of day-ahead commitments, real-time measurements, prosumer flexibility, and automated settlement within a single coordination model. The proposed work addresses these limitations by combining a complete Stackelberg leader–follower pricing formulation with blockchain-based automation, real-time demand response activation, and full peer-to-peer trading support. By deploying smart contracts on a scalable Proof-of-Stake blockchain and implementing the complete workflow from price publication to final settlement, the proposed framework provides a comprehensive and practically executable solution that extends beyond the scope of existing literature.
Blockchain-based OPF techniques are increasingly applied to P2P energy transactions, utilizing optimization strategies to ensure fair and reliable trading [32]. Several real-world initiatives exemplify the viability of energy markets utilizing blockchain, including the Brooklyn Microgrid, Power Ledger, Grid+, Siemens’ blockchain pilots, and LO3 Energy, all of which enable community-level peer-to-peer power trading [17]. While many existing studies focus on system-level modeling and optimization, the development and implementation of smart contracts for microgrid energy applications remain under-researched. Closing this gap is crucial to establishing a secure and trustworthy environment for energy exchange within local energy communities. This research addresses that need by developing and implementing smart contracts for day-ahead P2P energy trading and DR event coordination. The system is deployed on the Polygon blockchain mainnet, chosen for its low transaction costs and high throughput, making it ideal for scalable community microgrid applications. To optimize scalability and energy efficiency, the framework utilizes a Proof of Stake (PoS) consensus mechanism, which offers significantly lower energy consumption compared to traditional Proof of Work (PoW) methods [33,34,35]. Various consensus algorithms have been adopted in energy applications [36,37,38,39,40,41,42], with the present work employing the Polygon mainnet—a high-throughput, low-fee blockchain platform to support scalable and low-latency transactions across distributed energy nodes in a community microgrid. This framework uses the Proof of Stake (PoS) consensus protocol [33], which significantly reduces the energy burden associated with traditional Proof of Work (PoW) systems [34]. Unlike PoW, PoS relies on the staking of tokens rather than high-powered computational work to validate blocks. This approach not only improves energy efficiency but also ensures greater scalability and eco-friendliness in microgrid energy trading operations [43].
In addition to game-theoretic and blockchain-enabled coordination strategies, another well-established class of distributed control methods in microgrids is based on consensus algorithms. Consensus-based approaches enable multiple controllers (e.g., inverter controllers, distributed energy resource controllers) to agree on shared variables such as voltage setpoints, frequency, or incremental cost through iterative local communication without centralized orchestration (e.g., leaderless or primal–dual consensus). For example, recent work has applied distributed averaging and consensus optimization techniques to real-time voltage and frequency regulation in microgrids, demonstrating robust convergence properties under communication constraints [44]. Similarly, consensus strategies have been used to coordinate distributed energy resources for optimal power sharing and economic dispatch in smart grids [45]. Although these consensus-based methods are powerful for achieving agreement among physical controllers, they typically rely on continuous exchange of local states and do not incorporate economic incentives or enforce verifiable execution outcomes on a secure ledger. In contrast, the present work focuses on economic-level coordination through a blockchain-enabled Stackelberg pricing mechanism, where equilibrium pricing and demand response incentives are published and enforced via smart contracts. While consensus approaches aim at physical-layer agreement (e.g., voltage, frequency), our framework operates at the market-layer, coordinating prosumers and consumers with economic signals. In this sense, consensus-based electrical control and blockchain-based economic coordination can be viewed as complementary layers within a comprehensive microgrid energy management system.

1.3. Research Gaps and Contributions

Current research on microgrid energy management has shown strong progress in pricing models, demand response, and blockchain-based energy trading; however, these advances remain largely disconnected. Stackelberg-based pricing studies typically focus on the interaction between a central operator and consumers, without incorporating prosumer exports, battery storage dynamics, or renewable generation variability that shape real-time price behavior in modern microgrids. At the same time, blockchain-enabled P2P trading frameworks emphasize decentralization and transaction security but rarely integrate formal demand-side modelling, inconvenience costs, or feedback-based incentive mechanisms. Many demand response schemes continue to rely on static or predetermined incentives that fail to adapt to rapid shifts in load or renewable output. Additionally, most blockchain microgrid studies remain conceptual, lacking mathematically grounded equilibrium models that can be executed through smart contracts. Practical deployment is further limited because many implementations rely on costly blockchain networks rather than scalable, low-fee platforms suitable for frequent micro transactions. Finally, the literature lacks an end-to-end architecture that integrates real-time price regulation, DSM optimization, prosumer trading, storage operation, and on-chain settlement within a unified operational loop. While consensus-based distributed control strategies have been successfully applied for physical-layer objectives such as voltage/frequency regulation and distributed dispatch, they do not directly address market coordination with enforceable price signals. The proposed blockchain-enabled Stackelberg pricing framework fills this gap by providing incentive-compatible, verifiable, and auditable economic coordination among microgrid participants. This gap highlights the need for a coherent framework that unifies Stackelberg pricing, demand-side optimization, renewable-aware prosumer modeling, and blockchain-based market settlement for real-time microgrid operation. The proposed framework is intended for deployment in distribution-level microgrids and local energy communities where multiple prosumers and consumers participate in coordinated energy management. Typical application scenarios include residential community microgrids, university and hospital campuses, industrial parks, commercial complexes, and aggregator-managed distribution networks with high penetration of renewable energy sources and battery storage systems. The framework is suitable for both islanded and grid-connected operation, operating at supervisory and market-control time scales, while fast electrical control remains handled by conventional local controllers. By enabling automated pricing, demand response coordination, and transparent settlement, the proposed approach is particularly relevant to utilities, microgrid operators, and energy service companies seeking scalable, implementation-ready solutions for decentralized energy management.
Main Contributions:
  • A unified Stackelberg-based pricing framework is developed to regulate real-time energy prices while coordinating prosumer generation, battery storage, and consumer demand side flexibility in renewable-driven microgrids.
  • A demand side optimization component is introduced using a quadratic inconvenience cost and real-time DR incentive updates, enabling consumers to adjust consumption based on both price and system-level flexibility requirements.
  • A complete supply-demand balancing mechanism is proposed, where prices and DR incentives are iteratively updated using aggregate exports and loads until the system reaches a stable Stackelberg equilibrium.
  • A blockchain-based settlement layer is implemented on the Polygon PoS network, enabling transparent price publication, schedule commitment, DR verification, and automated payment execution with near-zero transaction cost.
The paper is organized as follows: The microgrid decentralized framework for managing energy utilization, utilizing smart meters, electrical networks, and communications configuration, is presented in Section 2 using mathematical modeling. Section 3 describes the peer-to-peer (P2P) energy transaction in the microgrid system utilizing blockchain technology. The findings and analyses in Section 4 are brought to a close with a case study that highlights the effectiveness of the proposed model and how blockchain can support this modeling approach for P2P energy exchanges and DSM. Section 5 then examines the conclusions.

2. System Modeling and Optimal Pricing Strategy Using Game Theory

The microgrid blockchain model framework, as illustrated in Figure 1, outlines the primary functional components employed in the proposed system. At the centre is the integrated model that links energy participants, game theoretic decision rules, blockchain smart contracts, and the transaction execution layer. These components work together to support secure peer-to-peer energy exchange and real-time demand side coordination. Game theory principles define the interaction between the microgrid energy management system and the market participants. The Stackelberg leader-follower structure guides the formation of prices. This structure drives mutually beneficial decisions and improves overall energy scheduling efficiency. The energy transaction model operates on the Polygon mainnet. This provides high security and fast processing with low operational cost. The model enables reliable financial settlement of peer-to-peer trades and ensures transparent recording of all market actions. Participants include consumers, prosumers, and battery energy storage systems. These units supply, consume, and store energy within the microgrid. They form the active market layer that responds to price signals and demand response events. Blockchain smart contracts facilitate the automation of market processes. They execute peer-to-peer energy trades, enforce pricing rules, record schedules, and validate demand response actions. This allows real-time coordination with a secure and tamper-proof execution environment.
(A) Microgrid Framework.
The microgrid is primarily modeled at an aggregated energy level to emphasize the proposed market coordination, Stackelberg pricing, and blockchain-based automation. The framework incorporates a distribution-level electrical modeling and validation layer to verify the physical feasibility of the optimized schedules. The proposed microgrid system consists of distributed renewable generation units (solar PV, wind), prosumers equipped with battery energy storage systems (BESS), and passive consumers connected through the Microgrid Energy Management System (MEMS), as shown in Figure 2. Each prosumer j ∈ N p generates renewable power G j , h at hour h , stores energy in a local battery S j , h , and consumes load L j , h . Each consumer i ∈ N c has a demand L i , h that can be partially shifted within the day based on demand response signals.
The MEMS coordinates real-time power balance and broadcasts an equilibrium price P h for every time slot h   =   1 , 2 , … , H . Energy transactions between prosumers and consumers are facilitated through a blockchain-enabled P2P market. All symbols and notations used in the manuscript are summarized in Appendix A.
(B) Renewable Generation and Battery Model.
Let the total renewable power generated by all prosumers at time h be
  G h = ∑ j ∈ N p G j , h .
Each prosumer uses a battery energy storage system characterized by charge and discharge power S j , h c h and S j , h d i s (both nonnegative). The State of Charge (SoC) at time h evolves as
  SoC j , h + 1 = SoC j , h + η c S j , h c h − S j , h d i s η d ,
where η c and η d are charging and discharging efficiencies.
The SoC is bounded as
  SoC j , m i n ≤ SoC j , h ≤ SoC j , m a x ,
and the operational power limits are
  0 ≤ S j , h c h ≤ S j , m a x c h , 0 ≤ S j , h d i s ≤ S j , m a x d i s .
At the end of the scheduling horizon H , the SoC is restored to its initial value:
  SoC j , H   =   SoC j , 0 .
(C) Aggregated Load and Grid Pricing Function.
The total load on the microgrid during the time slot h   is
  L h = ∑ i ∈ N c L i , h + ∑ j ∈ N p L j , h .
The MEMS determines the marginal grid price using a quadratic pricing function that captures time-of-use variation and dependency on total demand [31]:
  P h   =   α h L h + β h ,
where α h and β h are the grid coefficients varying with time and renewable intermittency.
The total grid cost of supplying load L h during hour h is
  C g r i d , h = 1 2 α h L h 2 + β h L h .
(D) Inconvenience Cost and Incentive Formulation.
Each consumer can adjust or shift part of its baseline load profile L i , h 0 .
The inconvenience cost associated with this load shifting is modeled as
  C i n c , i = ∑ h = 1 H θ i ( L i , h − L i , h 0 ) 2 ,
where θ i ∈ 0 , 1 denotes the inconvenience factor. Higher θ i values reflect reduced flexibility and increased discomfort.
During a Demand Response (DR) event, consumers receive an incentive proportional to their load reduction:
  R i , h   =   ϕ h L i , h 0 − L i , h ,
where ϕ h is the DR incentive coefficient broadcast by the MEMS. The net consumer cost is then
  C i , h n e t = P h L i , h + θ i ( L i , h − L i , h 0 ) 2 − ϕ h L i , h 0 − L i , h .
(E) Prosumers’ Revenue Function.
Each prosumer sells its surplus energy E j , h to peers or the grid, defined as
  E j , h = G j , h + S j , h d i s − S j , h c h − L j , h .
A positive E j , h denotes export, and negative indicates import.
The revenue function for prosumer j is
  U j , h = P h E j , h − η j S j , h c h + S j , h d i s ,
where η j is the degradation cost coefficient of the battery.
The daily prosumer profit is then
  U j = ∑ h = 1 H P h E j , h − η j S j , h c h + S j , h d i s .
(F) MEMS Objective and Power Balance Constraint.
The MEMS aims to minimize the total system cost, including energy purchase, user inconvenience, and grid cost:
  m i n P h ,   L i , h ,   S j , h C s y s   =   ∑ h = 1 H ( C g r i d , h + ∑ i C i n c , i , h − ∑ j U j , h ) ,
subject to:
  ∑ j E j , h   =   ∑ i L i , h , ∀ h ∈ 1 , … , H ,
and all operational constraints (3)–(5).
The proposed framework considers a grid-connected microgrid operating in parallel with the utility grid. As defined in Equation (12), the net surplus energy of each prosumer E j , h represents power that may be exchanged either through peer-to-peer transactions within the microgrid or with the external utility grid. In this formulation, the grid acts as an external source or sink that absorbs surplus generation or supplies deficit energy at the prevailing price P h , determined by the grid pricing function. The Stackelberg pricing and demand response mechanism coordinates local prosumers and consumers, while grid interaction provides balancing support. This modeling approach enables the proposed algorithm to operate effectively in grid-connected environments without restricting it to isolated microgrid operation.
(G) Game-Theoretic Pricing Formulation.
The microgrid is modeled as a non-cooperative game among users with MEMS as the Stackelberg leader.
Each consumer minimizes its cost:
  m i n L i , h J i   =   ∑ h = 1 H [ P h L i , h + θ i L i , h − L i , h 0 ) 2 − ϕ h L i , h 0 − L i , h .
Each prosumer maximizes its utility:
  m a x E j , h U j   =   ∑ h = 1 H P h E j , h − η j S j , h c h + S j , h d i s .
The MEMS acts as the leader that updates P h and ϕ h iteratively to balance total supply and demand:
  P h k + 1   =   P h k − δ p ( ∑ j E j , h k − ∑ i L i , h k ) ,
  ϕ h k + 1 = ϕ h k + δ r L T , h 0 − L T , h k ,
where δ p and δ r are step-size parameters controlling convergence.
The process converges to a Nash–Stackelberg equilibrium where:
  ∂ J i ∂ L i , h   =   0 , ∂ U j ∂ E j , h   =   0 , ∑ j E j , h   =   ∑ i L i , h .
At equilibrium, the price P h * reflects the marginal cost of supply, and all users reach their optimal schedules L i , h * , E j , h * .
(H) Convergence and Properties.
Because the individual cost functions J i and U j are strictly convex (quadratic) and the pricing function P h L h is affine, the collective game forms a monotone variational inequality problem, ensuring existence and uniqueness of equilibrium.
The distributed updates Equations (17)–(20) converge when step sizes satisfy 0 < δ p < 2 / L m a x , where L m a x is the Lipschitz constant of the aggregate supply–demand function.
The proposed framework assumes ideal communication and synchronized updates to facilitate analytical tractability and clarity of the Stackelberg formulation. In practical microgrid deployments, however, communication delays and measurement noise may arise due to network latency, asynchronous device operation, and sensor inaccuracies. Such non-idealities primarily affect the convergence speed of the iterative price and incentive updates rather than the existence of the equilibrium itself, provided that delays are bounded and measurement errors remain within acceptable limits. In practice, these effects can be mitigated through asynchronous or event-triggered update schemes, local buffering of price signals, and filtering of smart-meter measurements. Incorporating delay-tolerant update mechanisms and noise-aware estimation techniques into the blockchain-enabled control layer represents an important direction for future work toward large-scale and real-time implementations.
(I) Blockchain-Enabled Settlement.
After convergence, the MEMS finalizes the equilibrium quantities L i , h * and E j , h * and records the settled prices P h * on the blockchain. Smart contracts execute payment settlement as:
  Payment i   =   ∑ h P h * L i , h * , Revenue j   =   ∑ h P h * E j , h * .
Each transaction is transparent, tamper-proof, and auditable, ensuring fairness and traceability in the decentralized market.
The distributed Stackelberg pricing and demand-side management Algorithm 1 operates through an iterative interaction between the Microgrid Energy Management System (MEMS) and all users in the microgrid. At the beginning of the process, the MEMS computes the baseline demand and generates an initial price for each time slot based on the linear marginal pricing function. It also initializes the demand response incentive signals. In every iteration, the MEMS broadcasts the current energy price and incentive values to all consumers and prosumers. Each consumer then independently solves a local optimization problem that minimizes its individual cost. The cost includes the payment for energy consumption, a quadratic inconvenience cost that penalizes deviation from baseline demand, and the incentive linked to load reduction. This optimization yields the updated demand schedule for every consumer. In parallel, each prosumer solves its own optimization problem to maximize revenue obtained from exporting energy. The problem includes battery charging and discharging decisions, ensures feasible state-of-charge evolution, and respects operational limits. This step produces the updated export quantities and battery trajectories for all prosumers.
Algorithm 1. Distributed Stackelberg Pricing and Demand-Side Management in a Blockchain-Integrated Microgrid
Inputs:
  • Time H ; baseline loads L i , h 0 ; generation G j , h
  • Battery parameters S o C j , 0 , S o C j , m i n , S o C j , m a x , S j , m a x c h , S j , m a x d i s , η c , η d
  • Pricing coefficients α h , β h
  • Inconvenience factors θ i
  • Degradation factors η j
  • Step sizes δ p , δ r
  • Tolerance ε
Outputs:
  • Equilibrium price P h *
  • Optimal loads L i , h *
  • Optimal exports E j , h *
Algorithm:
  • Initialization:
    Compute
                      L h 0   =   ∑ i L i , h 0 , P h 0 =   α h L h 0 + β h .
Set k   =   0 .
Initialize ϕ h 0 .
2.
Broadcast:
MEMS sends P h k , ϕ h k to all users.
3.
Consumer update (parallel for all i ):
Solve
        m i n L i , h J i   =   ∑ h = 1 H [ P h k L i , h + θ i L i , h − L i , h 0 ) 2 − ϕ h k L i , h 0 − L i , h
subject to device limits.
Return L i , h k + 1 .
4.
Prosumer update (parallel for all j ):
Solve
              m a x E j , h ,   S j , h c h ,   S j , h d i s U j   =   ∑ h = 1 H P h k E j , h − η j S j , h c h + S j , h d i s
subject to
                      E j , h = G j , h + S j , h d i s − S j , h c h − L j , h ,                     S o C j , h + 1 = S o C j , h + η c S j , h c h − S j , h d i s η d ,                         S o C j , m i n ≤ S o C j , h ≤ S o C j , m a x ,                   0 ≤ S j , h c h ≤ S j , m a x c h , 0 ≤ S j , h d i s ≤ S j , m a x d i s ,                   S o C j , H = S o C j , 0 .
Return E j , h k + 1 .
5.
Aggregation at MEMS:
        L T , h k + 1 =   ∑ i L i , h k + 1 , E T , h k + 1 =   ∑ j E j , h k + 1 ,                 Δ h k + 1 =   E T , h k + 1 − L T , h k + 1 .
6.
Price update:
                  P h k + 1 =   P h k − δ p Δ h k + 1 .
7.
Incentive update:
              ϕ h k + 1 =   ϕ h k + δ r L T , h 0 − L T , h k + 1 .
8.
Convergence test:
If for all h:
              ∣ Δ h k + 1 ∣ ≤ ε , ∣ P h k + 1 − P h k ∣ ≤ ε ,
stop.
Else set k   =   k + 1 and return to Step 2.
Final Outputs
            P h *   =   P h k + 1 , L i , h * =   L i , h k + 1 , E j , h * =   E j , h k + 1 .
While the Stackelberg-based pricing and demand response framework guarantees economic equilibrium and convergence at the market level, it is also necessary to verify that the resulting schedules are physically feasible; therefore, an electrical modeling layer is introduced in the following section to evaluate voltage behavior, line loading, and network losses.
(J) Electrical Modeling Framework.
To verify the physical feasibility of the schedules obtained from the proposed Stackelberg pricing and demand response framework, an electrical modeling layer is incorporated at the distribution level [46,47]. This layer operates independently of the market optimization and is used exclusively to evaluate voltage behavior, line loading, and network losses corresponding to the optimized schedules.
Nodal Power Injection Representation:
For each scheduling time slot h ∈ H , the optimized market outcomes are mapped to nodal power injections. The net active power injection at bus a ∈ N is defined as
  p a , h i n j = E j , h , if   bus   a   corresponds   to   prosumer   j , − L i , h , if   bus   a   corresponds   to   consumer   i , P h g r i d ,         if   a   is   the   PCC .
Here, E j , h denotes the net power exported by the prosumer j , as defined in Equation (12), and L i , h represents the scheduled electricity demand of consumer i . Positive values of p a , h i n j indicate net power injection into the distribution network, while negative values represent net power consumption.
Reactive power injections q a , h i n j are modeled using a fixed power factor assumption and follow the same sign convention as the corresponding active power injections.
Distribution Power Flow Model:
Electrical feasibility is evaluated using a linearized distribution power flow formulation suitable for radial low-voltage networks. For each distribution line a , b ∈ L , the squared voltage magnitude relationship is expressed [47] as
  V b , h = V a , h − 2 r a b P a b , h + x a b Q a b , h ,
where V a , h and V b , h are the voltage magnitudes at buses a and b , respectively, and P a b , h and Q a b , h denote the active and reactive power flows on line a , b at time slot h . The parameters r a b and x a b represent the resistance and reactance of the distribution line.
Nodal power balance is implicitly enforced through the aggregation of downstream injections, and the voltage magnitude at the point of common coupling is fixed at V a , h   =   1.0 pu.
Electrical Operating Constraints:
The following electrical constraints are evaluated for all buses, lines, and time slots:
  • Voltage magnitude limits
    V a m i n ≤ V a , h ≤ V a m a x , ∀ a ∈ N , | h ∈ H ,
  • Line thermal limits
P a b , h 2 + Q a b , h 2 ≤ S a b m a x , ∀ ( a , b ) ∈ L , | h ∈ H ,
where V a m i n and V a m a x denote the minimum and maximum allowable voltage magnitudes, and S a b m a x is the apparent power rating of line a , b .
Loss Modeling:
Real power losses on each distribution line are approximated as
  P a b , h l o s s = r a b P a b , h 2 + Q a b , h 2 V a , h ,
and aggregated across all lines and time slots to quantify total network losses. This formulation enables the evaluation of the efficiency impact of the proposed market-based scheduling decisions without altering the underlying optimization problem.
Once all users have sent their optimized responses, MEMS aggregates the total demand and total exported energy in every time slot. It computes the power imbalance as the difference between exports and demand. This imbalance drives the update of the energy price according to a distributed gradient rule. If exports exceed demand, the price decreases; if demand exceeds exports, the price increases. At the same time, the MEMS updates the demand response incentive. The incentive increases when actual demand remains above the baseline and decreases when load shifting is successful. These updates shape user behavior over successive iterations. After applying both updates, the MEMS checks whether the system has converged. Convergence is reached when the power imbalance and successive price changes fall below a predefined tolerance. If the conditions are not satisfied, the algorithm proceeds to the next iteration. When convergence occurs, the resulting price, demand schedules, and export schedules represent the Stackelberg equilibrium. These values define the optimal operating point of the microgrid, where consumers and prosumers have responded optimally to the leader’s price signal, and the MEMS has achieved a balanced market with minimal cost. The equilibrium quantities are then transmitted to the blockchain layer for final settlement through smart contracts. Although the proposed algorithm operates through iterative price and incentive updates, it can therefore accommodate dynamic changes in system constraints. Planned variations, such as scheduled maintenance or updated generation forecasts, can be incorporated by revising power and energy limits between scheduling intervals. In the presence of emergency events, including unexpected outages or sudden capacity reductions, the framework can be re-initialized with updated constraints and real-time measurements, enabling the system to converge toward a new feasible operating point.

3. P2P Energy Transaction and Demand Side Management with Blockchain Implementation

To efficiently utilize distributed generations (DGs), primarily solar PV and wind energy, we suggest a local power market architecture for microgrid communities comprising prosumers and consumers, aiming to promote peer-to-peer (P2P) trade. Battery storage is used with each prosumer for reliable local P2P hourly energy trading due to the intermittent nature of RES. The objective of this community microgrid is to provide self-sufficiency in meeting its energy demands and minimize electricity costs compared to utility grids. Microgrid EMS plays a crucial role in load-generation optimization, verifying all power system technical parameter violations by running the Linearized Distribution Power Flow (LinDistFlow) formulation and energy scheduling operations, and providing an interface to the blockchain network, as blockchain is not capable of handling complex mathematical calculations. Through the use of bidirectional information flow, user-end smart meters, Internet of Things devices, and Message Queuing Telemetry Transport (MQTT) are interfaced with Application Programming Interfaces (API), and blockchain applications maximize the true benefits to the distribution system.
With blockchain-enabled peer-to-peer (P2P) energy trading, consumers can sell excess electricity directly to local users, eliminating the need for a middleman and enabling a successful community microgrid business model. Consumers might pay less per kWh and indicate their preference for renewable energy without owning the equipment, while prosumers could profit from this arrangement by earning more than they would under feed-in tariffs. Auctions for renewable electricity can create a thriving market that benefits both consumers and prosumers, as untraded power can be stored in batteries. Network providers and electricity retailers can benefit from a more effective market with lower-cost infrastructure. By removing market middlemen, blockchain-based solutions also provide confidentiality and security to both prosumers and consumers. Real-time matching of energy supply and demand occurs between participants with similar energy demand profiles, and trade is carried out exclusively through blockchain smart contracts [48,49,50,51,52].
On the Ethereum blockchain, smart contracts are automated programs written in Solidity that are executed when the conditions of a peer-to-peer agreement are met, without the need for third-party intervention. The energy flexibility profiles of each user (consumers, prosumers/RES aggregators) for participation in DR programs are defined here using smart contracts, along with guidelines for automatically ensuring grid-level demand and generation balance. This collection of guidelines outlines how each participant should behave during DR occurrences while keeping limitations within reasonable bounds to preserve grid characteristics and, consequently, the microgrid system’s stability and dependability. When fresh energy transfers occur, these smart contracts, stored on the blockchain, are activated, as shown in Figure 3. After each smart contract is completed, blockchain nodes continue to update their states. The smart contract may be activated at any time after successful deployment and functions as an agent on the blockchain, with state variables that enforce the relevant rules. Smart contracts automatically control each user’s voluntary participation in a DR event. The smart contract defines individual baseline load demand profiles, current load profiles, predicted load profiles, and energy flexibility adjustment values that must be updated throughout the DR event. The microgrid system’s load-generation balance toward self-sufficiency is achieved through the widespread use of automated DR systems [53,54].
Figure 4 illustrates the registration and transaction workflow among prosumers, consumers, the Registration Authority, and the Microgrid Energy Management System (MEMS). Participants register using their public keys, and the identities of accepted participants are recorded. Once a transaction request is initiated, it is forwarded to MEMS, where the Stackelberg price update is executed. The best responses from prosumers and consumers are aggregated and broadcast to the blockchain execution layer, where smart contracts store updated prices and energy quantities, validated by blockchain nodes before new blocks are appended.
To ensure transparent, tamper-proof, and verifiable execution of all energy market decisions, the proposed framework integrates a dedicated blockchain smart contract deployed on the Polygon Proof of Stake network. The smart contract serves as the digital backbone of the microgrid market, providing a trusted storage mechanism for prices, day-ahead schedules, demand response parameters, real-time measurements, and settlement outcomes. All interactions between the Microgrid Energy Management System (MEMS), prosumers, and consumers are recorded as on-chain transactions, enabling secure automation of the full operational cycle. The design is divided into two layers. Algorithm 1 describes the day-ahead phase, including participant registration, price publication, and schedule commitment. Algorithm 2 handles the real-time phase, including DR event execution, smart meter measurements, and financial settlement.
Algorithm 2. Day-Ahead Price Publication and Schedule Commitment
Given:
  • Time horizon h ∈ 1 , … , H
  • Day index d
  • Participants U = U c ∪ U p
  • Stackelberg prices P h * d
  • Consumer optimal loads L i , h * d
  • Prosumer optimal exports E j , h * d
Output:
  • On-chain price vector { P h d } h = 1 H
  • Committed schedule q a ′ , h d for each address a ′
Step 1. Contract Initialization
1.1
networkAdministrator ← msg . sender
1.2
drEventActive ← false
1.3
Initialize mappings
          participants [ a ′ ] , | priceSchedule [ d ] [ h ] , | schedule a ′ [ d ] [ h ] , |               measurement a ′ [ d ] [ h ] , | settlement a ′ [ d ] .
Step 2. Participant Registration
For any address a ′ :
2.1
If participants a ′ . isRegistered   =   1 , reject.
2.2
Otherwise set
      participants a ′ . isRegistered   = 1 ,   participants a ′ . isProsumer ∈ 0 , 1 ,       participants a ′ . G m a x ,   participants a ′ . S m a x ,   participants a ′ . meterID .
Step 3. Day Initialization
If d > currentDayID , then
                      currentDayID ← d .
Step 4. Price-Schedule Publication
For all h ∈ 1 , … , H :
                    priceSchedule d h = P h * d .
Step 5. Submission of Optimal Schedules
For a consumer i   with address a i ′ :
                            q a i ′ , h d = L i , h * d .
For a prosumer j   with address a j ′ :
                            q a j ′ , h d = E j , h * d .
Smart contract enforces:
  • Consumer nonnegativity:
                                  q a ’ i , h d ≥ 0 .
  • Prosumer feasibility:
                            0 ≤ q a j ′ , h d ≤ G j , m a x + S j , m a x .
    Store committed schedule:
                          schedule a ′ d h = q a ′ , h d .
Algorithm 2 describes how the blockchain smart contract manages all day-ahead price signals and schedules commitments prior to the start of real-time operation. When the smart contract is first deployed, the network administrator’s address is stored, and internal data structures for prices, schedules, measurements, and settlements are initialized. Each user who wishes to participate in the microgrid market must register on the chain by submitting their role, generation and storage capacities, and meter identifier. The contract verifies that the user has not previously registered and then records all technical parameters as immutable participant attributes. At the start of each new operating day, the network administrator triggers a day initialization, which updates the current day index and prepares the contract to store new operational data. The Microgrid Energy Management System then computes the Stackelberg equilibrium price for each time slot and publishes the entire day-ahead price vector to the blockchain. These values are written directly into the contract’s price schedule and become the authoritative price signals for all market participants.
After prices are published, each user must commit their optimal day-ahead schedule to the blockchain. For consumers, this is their optimal demand L i , h * d , and for prosumers, it is their optimal export E j , h * d . The contract enforces physical feasibility by checking that consumer loads are non-negative and that prosumer exports do not exceed the combined limits of renewable generation and storage capacity. Only schedules that satisfy these constraints are accepted and stored as q a ’ , h d for each address. These committed quantities form binding contractual obligations for the next day’s operation. By recording the price vector and all user schedules immutably on the chain, the smart contract ensures transparency, prevents disputes, and establishes a verifiable baseline for subsequent real-time measurement, DR events, and financial settlement.
Algorithm 3 governs the real-time execution of the microgrid market, ensuring that all demand response (DR) actions, meter readings, and financial transactions are processed transparently through the blockchain smart contract. Once the day-ahead schedules and price signals have been committed on the chain, the Network Administrator activates a DR event whenever system conditions require load reduction within a designated time window. The smart contract records the DR start and end slots, the required system-level reduction, and the incentive and penalty rates that will govern user compensation. This activation establishes the contractual rules that all participants must follow during the specified period. During real-time operation, each participant’s smart meter periodically submits its actual power profile to the blockchain using a trusted oracle. For every time slot, the contract stores the measured consumption or export m a ’ , h d , ensuring that all subsequent calculations rely on verifiable and immutable data. After the DR window finishes, the contract computes each consumer’s contribution to demand reduction by comparing the baseline value L i , h 0 with the measured value. The difference, if positive, represents a valid load reduction Δ L i , h . Summing across all affected hours yields each user’s total DR contribution Δ L i D R , while summing across all consumers yields the system-level reduction Δ L T D R .
Algorithm 3. Real-Time DR Execution, Measurement, and Settlement
Given:
  • Baseline loads L i , h 0
  • Metered values m a ′ , h d
  • DR window h s ≤ h ≤ h e
  • Required reduction R req
  • Incentive rate γ DR
  • Penalty rate γ pen
Output:
  • DR reductions Δ L i , h
  • System reduction Δ L T D R
  • Consumer payments
  • Prosumer revenues
    Step 1. DR Event Activation
    Set
                      drEventActive = 1 ,   drDayID = d ,                   drStart = h s ,   drEnd = h e ,                       R req = R req , γ DR = γ DR , γ pen = γ pen .
    Step 2. Real-Time Measurement Logging
    For each address a ′ and slot h :
                      measurement a ′ d h = m a ′ , h d .
    Step 3. DR Reduction Calculation
    For each consumer i :
3.1
Slot-wise reduction:
              Δ L i , h = max { L i , h 0 − m i h ( d ) , | 0 } , h s ≤ h ≤ h e .
3.2
Total consumer reduction:
                    Δ L i D R   =   ∑ h = h s h e Δ L i , h .
3.3
System reduction:
                    Δ L T D R = ∑ i ∈ U c Δ L i D R .
3.4
DR success factor:
                κ   =   { 1 , Δ L T D R ≥ R req , Δ L T D R R req , Δ L T D R < R req .
Step 4. Consumer Settlement
For each consumer i :
4.1
Energy cost per slot:
                  C i , h   =   P h d   m i , h d .
4.2
DR incentive (only for h s ≤ h ≤ h e ):
                    I i , h = κ   γ DR   Δ L i , h .
4.3
Penalty for deviation from committed schedule:
              Π i , h = γ pen m a x m i , h d − q i , h d , 0 .
4.4
Net daily payment:
                  Payment i = ∑ h = 1 H C i , h − I i , h + Π i , h .
Store:
                    settlement i d = Payment i .
Step 5. Prosumer Settlement
For each prosumer j :
5.1
Revenue per slot:
                  R j , h = P h d   m j , h d .
5.2
Penalty for under-delivery:
              Π j , h = γ pen m a x q j , h d − m j , h d , 0 .
5.3
Net daily revenue:
                  Revenue j = ∑ h = 1 H R j , h − Π j , h .
Store:
                  settlement j d = Revenue j .
The smart contract then determines whether the DR target was fully achieved. If the total reduction meets or exceeds the required amount, a success factor κ = 1 is applied. Otherwise, incentives are proportionally scaled by the ratio κ = Δ L T D R / R req , ensuring fairness and preventing overpayment during partial fulfilment. Settlement is then performed individually for every participant. Consumers are charged an energy cost P h d   m i , h d for each time slot, granted DR incentives for valid reductions, and penalized when their actual demand exceeds their committed day-ahead schedule. The net financial obligation is computed as the sum of all energy costs, incentives, and penalties across the entire horizon. Similarly, prosumers receive revenue from the sale of their exported power at the published price but are penalized if they fail to deliver the committed quantity. Their final revenue is computed as the sum of export payments minus under-delivery penalties. All outcomes are stored on the chain in the settlement ledger, providing a transparent, auditable record of daily financial transactions. Finally, the DR event is closed, and all data, from price signals to measurements and settlements, remains permanently accessible on the blockchain, ensuring accountability and supporting future system-level analysis.

4. Results and Analysis

The Stackelberg game formulated in Section 2 is implemented for a 10-user community microgrid comprising 8 prosumers and 2 consumers, evaluated over 24 hourly time slots. Realistic residential load and generation profiles are adopted from the Pecan Street dataset [55]. The proposed framework is assessed with respect to pricing dynamics, demand response participation, prosumer energy exchange, and system-level performance. The networked microgrid configuration used for validation is shown in Figure 5. The system is a grid-connected low-voltage radial feeder with a point of common coupling (PCC) acting as the slack bus. Table 2 summarizes the distribution line parameters of the low-voltage radial feeder used for electrical validation, providing the electrical characteristics required to assess voltage profiles, line loading, and network losses under the optimized schedules. This configuration maps optimized schedules to nodal injections for distribution-level power-flow analysis. The resulting voltage profiles, line loading, and network losses over the 24-h horizon are summarized in Table 3, confirming the electrical feasibility of the proposed framework.
Over the full 24-h horizon, the minimum and maximum bus voltage magnitudes are 0.999488 pu and 1.002214 pu, respectively, occurring at Bus 1 (Hour 19) and Bus 10 (Hour 7). These values lie well within the allowable voltage range V a m i n , V a m a x , indicating that market-driven coordination does not induce voltage deviation. Line loading analysis shows a maximum utilization of only 22.81% on line (2–3) during Hour 7, demonstrating substantial thermal margin and confirming that the integration of real-time pricing, demand response, and prosumer battery scheduling does not lead to network congestion, even under peak operating conditions. Furthermore, the total daily network energy loss is limited to 0.5788 kWh, with a peak hourly loss of 0.0256 kW, highlighting efficient local balancing of supply and demand enabled by decentralized prosumer participation.
The Microgrid Energy Management System (MEMS) acts as the Stackelberg leader and broadcasts hourly prices, while prosumers and consumers act as followers, updating their export and demand schedules to minimize individual costs or maximize revenues. At each iteration, the MEMS updates the prices and demand response incentives according to the aggregate supply demand imbalance until the system converges to a Stackelberg equilibrium that satisfies the power balance constraint and the optimality conditions of Equations (17)–(20). Simulation results confirm that, for each of the 24 h in the 24-h horizon, the price update dynamics converge, and the final microgrid price lies between the utility import tariff and the surplus-to-grid export tariff. This satisfies the game-theoretic requirement that the equilibrium price remains attractive for both sellers and buyers. Prosumers earn higher revenue than when selling directly to the grid, while consumers pay a lower price than the utility grid rate. The game’s outcome, therefore, aligns individual incentives with system-level objectives. Equation (17), implemented through iterative price and quantity updates, identifies the optimal pricing strategy for each hour, allowing users to adjust their loads and storage operations in response to these signals.
To interact with the blockchain network and Microgrid EMS, all users are connected to smart meters, Internet of Things devices, and communication systems. To increase flexibility and dispatchable energy in the microgrid system for P2P energy transactions utilizing blockchain trading platforms, we have focused solely on battery storage systems (BESS) and prosumers. BESS owned by prosumers is charged during periods of prosumer excess generation and discharged during the microgrid’s peak load. Local P2P energy trading is based on the battery SoC level, as defined in the smart contract on the blockchain, and is determined by the battery’s discharging logic, as shown in Figure 6. The total hourly load profiles of the prosumers after meeting their demand through local generation and those of the consumers in the microgrid are shown in Figure 7. The total renewable energy generations of the microgrid are shown in Figure 8. The surplus power associated with prosumers can be used for P2P energy transactions within the MG or to charge the BESS. If prosumers are deficient in power, they can purchase power either from the utility grid or from local distributed generators through peer-to-peer (P2P) energy trading and are considered buyer-like consumers. The total hourly battery charging level and the microgrid’s grid consumption are shown in Figure 9 and Figure 10, respectively. Prosumers with surplus power after meeting their own demand can sell it to buyers within the microgrid at a lower price than the utility grid, determined by a dynamic optimal pricing strategy based on the Stackelberg equilibrium. Prosumers with bulk PV power generation can sell power to consumers, charge their batteries, and help support the microgrid’s energy balance. Once the microgrid’s local requirements have been met, the remaining electricity can be sold to the grid. A certain amount of electricity will be required from the utility grid to meet the consumer’s demand when local generation falls short, as shown in Figure 10.
Equation (17), based on game theory, computes the simulation outcome by determining the optimal pricing strategy that benefits all users, sellers, and purchasers. After that, the microgrid transaction model was examined and assessed. According to the calculations, users can increase their income by transferring loads at the proper time. For local customers from microgrid generations, the best price at any given time falls between the grid price and the price of “surplus power to the grid.” During peak hours, when power demand is high, microgrid users adjust their loads accordingly.
BESS Parameters:
Initial battery charge: 1 kWh; battery capacity: 4 kWh; charging efficiency: 98%; maximum charging rate: 2.5 kW; discharge efficiency: 96%; maximum discharge rate: 2.5 kW.
The bar chart in Figure 11 compares the hourly electricity price λ before and after the application of Stackelberg-based pricing optimization. The blue bars represent the original marginal price profile driven by uncoordinated demand and renewable variability, while the orange bars show the adjusted price λ*(h) obtained after the leader–follower game reaches equilibrium. Across the 24-h horizon, the optimized prices consistently decrease relative to the baseline. The reduction is most pronounced during the evening peak hours (17:00–21:00), where high demand previously elevated the marginal price. After optimization, the price drop during these hours indicates successful peak shaving and an improved supply–demand balance, enabled by strategic prosumer exports and consumer load shifting. During solar-rich midday hours (10:00–15:00), the price reduction is smaller, which aligns with the presence of local renewable generation and naturally lower demand pressure.
The uniform downward shift across all hours confirms that the Stackelberg mechanism reduces system stress and enhances pricing efficiency by coordinating consumption flexibility and prosumer behavior. The price flattening also reflects increased renewable utilization and reduced grid dependence. Therefore, the optimized Stackelberg equilibrium produces a more stable, lower-cost price trajectory that benefits both consumers and prosumers while ensuring system-level balance.
The P2P energy trading model, utilizing battery storage and the PCDG v1.0 software from NUST [57], is shown in Figure 12 and Figure 13. P2P trading with battery storage has been found to yield superior outcomes in terms of cost savings, peak curtailment via battery discharge, and grid demand reduction, enabling the self-sustainable operation of the microgrid with RES. The total trade volume for 10 residents is illustrated in Figure 12. A house equipped with a battery can import and export energy as needed.
By evaluating each house’s entire trading status, which is also its net energy position, this flexibility is recorded. Simply said, it is the difference between the energy that each household imports and exports. The representation provides an additional layer that makes it easier to trace energy flow and determine who provided or received it. The trade display depiction of the energy exchanged between the various residences is shown in Figure 13. The energy sent from one home and received by another is not exactly equal because P2P transfers are subject to underlying system losses. The total energy received by a particular house over the entire trade period may thus be used to accurately estimate the P2P energy trading volume of the houses on the trading display. By sharing battery storage among several peers, the community microgrid can trade energy, as shown in Figure 12.
It also aims to provide a blockchain-based transaction platform that enables consumers to transact among themselves, become more independent in meeting their electricity needs, and reduce their reliance on the main grid. The second objective of the research is to manage demand on the demand side during peak grid conditions. The DSO generates the DR signal for the microgrid EMS to shift the load according to the DR program. An EMS integrated with blockchain broadcasts the information to all peers and runs the Smart Contract program to shift load and discharge batteries to support the utility grid. The DSM using game theory is described in Section 2, which minimizes the cost and PAR. Simulation results show that the PAR is significantly reduced, as shown in Figure 14. After shifting the load curve during peak hours, the cost curve is also significantly shifted, resulting in a reduction in cost, as shown in Figure 14. Therefore, DSM can benefit not only microgrid users who can adjust their loads during peak hours to reduce their electricity bills, but also the utility grid, which will experience reduced burden during these hours. The overall cost of the microgrid is also reduced due to load shifting, as shown in Figure 15. The types of appliances and their consumption profiles, along with their willingness to shift the load, are shown in Table 4.
Every transaction is also traceable, transparent, extremely safe, and unchangeable. Considering the benefits to the economy and the environment, a blockchain-integrated microgrid system offers a more effective solution to the distribution system’s problems than a microgrid system alone. The rapid sharing of information through the blockchain-integrated system enables all microgrid system users to benefit from the proposed DSM methodologies. Blockchain users will sell their excess energy during peak hours and store it during off-peak hours, after meeting their local load requirements. Because a certain number of prosumers are also included in the microgrid model, the utility grid will also benefit during peak hours by satisfying the increased generating demand from the microgrid.
The provided metrics shown in Table 5 outline the financial impacts of implementing a Demand Response (DR) program within a microgrid system. Before the DR program, the microgrid incurred various costs, including energy sold by prosumers, energy bought by consumers, microgrid operational costs, aggregated battery storage costs, and an absence of inconvenience costs for consumers. After implementing the DR program, noticeable changes in these financial metrics are observed. Energy sold by prosumers increased from $19.50 to $23, indicating a more efficient utilization of RES and BESS resources within the microgrid. Similarly, energy bought by consumers decreased from $25 to $22, reflecting optimized consumption patterns and potentially lower energy demand during peak periods. One notable change is a reduction in microgrid operational costs from $19.93 to $17.94. This $1.99 decrease suggests potential efficiency gains and better resource utilization facilitated by the DR program. Additionally, the introduction of inconvenience costs for consumers, amounting to $1.50, indicates a shift in the cost structure to account for reliability or service level agreements. Overall, these changes culminate in total cost savings of $6.99, highlighting the positive financial impact of implementing the DR program on the microgrid’s operational efficiency and cost management.
The blockchain evaluation metrics, as shown in Table 6, confirm that the Polygon PoS network provides sufficiently fast and low-cost settlement for real-time microgrid applications. DR event triggers and price updates consistently finalize within 2 s, while P2P trade settlements remain below 2.2 s. Gas fees range between 0.0001 and 0.0003 USD per transaction, enabling continuous DR signaling and high-frequency energy trading without economic overhead. All smart contract executions completed successfully during 500 test cycles, demonstrating the robustness of the proposed architecture. With a throughput of more than 7000 TPS and a finality window under 3 s, the blockchain layer reliably supports the high communication demands of decentralized microgrid operations.
Unlike centralized DR, which requires full system observability and centralized optimization, the proposed framework enables distributed coordination through a Stackelberg leader–follower structure with real-time pricing and incentive updates. Compared to conventional P2P trading schemes, the proposed approach explicitly integrates demand response, prosumer battery dynamics, and automated blockchain-based settlement within a unified framework. This comparison in Table 7 highlights that the primary added value of the proposed method lies in its ability to combine real-time economic coordination, scalability, and practical implementation feasibility.
The case study presented in this work is based on real-world residential consumption and distributed generation data obtained from the Pecan Street dataset, ensuring that the evaluated demand response behavior and renewable generation profiles are representative of practical microgrid environments. A limited number of users are selected to provide transparency in illustrating the proposed Stackelberg pricing and blockchain-enabled coordination mechanisms. This choice does not restrict the generality of the proposed framework, as the underlying optimization, distributed updates, and settlement processes are inherently scalable with the number of participants. In larger systems with higher renewable penetration, increased prosumer participation, or stressed operating conditions, the same modeling and coordination principles apply, with scalability primarily affecting computational and communication aspects rather than the fundamental control logic. Comprehensive large-scale and stress-test evaluations using extended datasets are identified as important directions for future work.

5. Conclusions

This work presented a blockchain-integrated Stackelberg pricing framework for real-time price regulation and demand-side optimization in renewable-driven community microgrids. By combining rigorous mathematical modeling, game-theoretic decision-making, and smart contract execution, the proposed approach provides a transparent, secure, and economically efficient energy management architecture specifically designed for decentralized energy systems. The Stackelberg leader–follower formulation enables the Microgrid Energy Management System (MEMS) to broadcast dynamic price and incentive signals that reflect aggregate demand conditions and renewable availability, while consumers and prosumers respond optimally by adjusting consumption, energy exports, and charging and discharging schedules for batteries. The interaction between the MEMS and participating agents converges to an equilibrium that balances supply and demand, reduces peak load, improves utilization of renewable energy, and preserves user comfort through explicit inconvenience-cost modeling. Prosumers benefit from increased revenues by exporting energy during high-price periods, while consumers lower their total energy costs by shifting flexible loads to low-price intervals. The blockchain layer plays a supporting but essential role by enabling automated execution, immutable record-keeping, and transparent settlement of prices, schedules, measurements, and payments. Deployment on a low-fee Proof-of-Stake platform ensures practical feasibility without imposing excessive transaction overhead. Importantly, beyond market-level performance, the study explicitly verifies the electrical feasibility of the optimized schedules using a distribution-level power flow modeling layer. The electrical validation confirms that all bus voltages, line loadings, and network losses remain within acceptable limits over the full 24-h horizon, demonstrating that the proposed market-driven coordination is compatible with fundamental distribution network constraints. The framework, therefore, operates at a supervisory and market-control time scale, complementing existing fast electrical control and protection layers rather than replacing them, and is applicable to both grid-connected and islanded microgrids.
While the present study emphasizes aggregated energy modeling and executable market coordination, the following meaningful directions for future work are identified as:
(i).
integration with optimal power flow (OPF) modules to enable closed-loop enforcement of voltage, thermal, and congestion constraints;
(ii).
incorporation of battery degradation-aware cost models, dynamic consumer price acceptance limits, and more detailed behavioral heterogeneity;
(iii).
extended robustness and scalability analysis under large-scale deployments, uncertainty, and asynchronous communication; and
(iv).
enhanced cyber–physical security mechanisms, including intrusion detection, resilience-aware control strategies, and adversarial or collusive participant behavior.

Author Contributions

Conceptualization: A.U.; Methodology: A.U. and V.G.; Software: A.U., N.G., V.G. and A.K.; Validation: A.U., P.K.J., D.K., N.G., V.G. and A.K.; Formal analysis: A.U., D.K. and V.G.; Investigation: A.U., P.K.J., D.K., N.G., V.G. and A.K.; Resources: D.K., N.G. and A.K.; Data curation: D.K., N.G. and A.K.; Writing—original draft preparation: A.U. and V.G.; Writing—review and editing: P.K.J., D.K., N.G. and A.K.; Visualization: A.U., P.K.J., N.G., V.G. and A.K.; Supervision: P.K.J. and D.K.; Project administration: P.K.J.; Funding acquisition: P.K.J. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Collaborative Research Program of Nazarbayev University, grant number 111024CRP2007.

Data Availability Statement

The datasets generated and/or analysed during the current study are available from the corresponding author on reasonable request.

Acknowledgments

The authors gratefully acknowledge the utilization of the hardware setup under the Research Initiation Grant from Punjab Engineering College (Deemed to be University), Chandigarh, vide Memo No. PEC/DSR&C/54 dated 10 April 2024.

Conflicts of Interest

The authors declare that there is no conflict of interest with any financial organizations regarding the material reported in this manuscript. The authors declare no competing interest.

Abbreviations

MGMicrogrid
MEMSMicrogrid Energy Management System
DERDistributed Energy Resource
BESSBattery Energy Storage System
DRDemand Response
DSMDemand-Side Management
P2PPeer-to-Peer
DLTDistributed Ledger Technology

Appendix A. Nomenclature and Notation

Table A1. Sets, Indices, and Identifiers.
Table A1. Sets, Indices, and Identifiers.
SymbolDescription
h = 1 , 2 , … , H Hourly scheduling time slot
H Scheduling horizon
d Operating day index
k Iteration index of the Stackelberg update
i ∈ N c Consumer index and set
j ∈ N p Prosumer index and set
a ′ ∈ U = U c ∪ U p Blockchain participant address
U c Set of consumer addresses
U p Set of prosumer addresses
Table A2. Renewable Generation, Load, and Energy Variables.
Table A2. Renewable Generation, Load, and Energy Variables.
SymbolDescription
G j , h Renewable generation of prosumer j at hour h
G h Total renewable generation, G h   =   ∑ j ∈ N p G j , h
L i , h Electricity demand of consumer i at hour h
L j , h Electricity demand of prosumer j at hour h
L h Total microgrid load at hour h
E j , h Net energy exchanged by prosumer j (export > 0 , import < 0 )
Δ L i , h Load reduction of consumer i due to demand response
Table A3. Battery Energy Storage Variables.
Table A3. Battery Energy Storage Variables.
SymbolDescription
S j , h c h Battery charging power of prosumer j
S j , h d i s Battery discharging power of prosumer j
S o C j , h State of charge of prosumer j ’s battery
η c Battery charging efficiency
η d Battery discharging efficiency
S o C j , m i n Minimum allowable battery state of charge
S o C j , m a x Maximum allowable battery state of charge
S j , m a x c h Maximum charging power
S j , m a x d i s Maximum discharging power
Table A4. Pricing and Grid Cost Variables.
Table A4. Pricing and Grid Cost Variables.
SymbolDescription
P h Electricity price broadcast by MEMS at hour h
P h * Converged equilibrium electricity price
α h Grid pricing coefficient (demand sensitivity)
β h Grid pricing coefficient (base price)
C g r i d , h Grid energy procurement cost at hour h
Table A5. Demand Response and Incentive Variables.
Table A5. Demand Response and Incentive Variables.
SymbolDescription
L i , h 0 Baseline demand of consumer i at hour h
θ i Consumer inconvenience (flexibility) coefficient
ϕ h Demand response incentive coefficient
C i n c , i Inconvenience cost of consumer i
C i , h n e t Net cost of consumer i at hour h
Table A6. Objective, Utility, and System Cost Variables.
Table A6. Objective, Utility, and System Cost Variables.
SymbolDescription
J i Cost function minimized by consumer i
U j , h Revenue of prosumer j at hour h
U j Total profit of prosumer j over the horizon
C s y s Total system cost minimized by MEMS
Table A7. Game-Theoretic Update and Convergence Parameters.
Table A7. Game-Theoretic Update and Convergence Parameters.
SymbolDescription
δ p Price update step size
δ r Incentive update step size
Δ h Supply–demand imbalance at hour h
ε Convergence tolerance
L m a x Lipschitz constant of aggregate response
Table A8. Blockchain Scheduling and Settlement Variables.
Table A8. Blockchain Scheduling and Settlement Variables.
SymbolDescription
q a ′ , h d Day-ahead committed schedule of address a ′
m a ′ , h d Real-time metered power of address a ′
P a y m e n t i Total daily payment of consumer i
R e v e n u e j Total daily revenue of prosumer j
R r e q Required demand response reduction
γ D R Demand response incentive rate
γ p e n Penalty rate
κ Demand response success factor
Table A9. Electrical Modeling.
Table A9. Electrical Modeling.
SymbolDescription
a ∈ N Bus Index in the microgrid
a , b ∈ L Distribution line connecting buses a and b
P a b , h Active power flow on line a , b at time h
Q a b , h Reactive power flow on line a , b at time h
V a , h Voltage magnitude at bus a at time h
V a m i n Minimum allowable voltage magnitude at bus a
V a m a x Maximum allowable voltage magnitude at bus a
S a b m a x Apparent power (thermal) limit of line a , b
r a b Resistance of line a , b
x a b Reactance of line a , b
P a b , h loss Active power loss on line a , b   at time h

Appendix B. Extended Mathematical Modelling

This appendix provides additional derivations and mathematical details that complement the formulations in Section 2. The complete Stackelberg-based optimization model is expanded to show intermediate steps and auxiliary expressions that are omitted from the main text for clarity.

Appendix B.1. Prosumer Battery State Dynamics

For each prosumer j , the charging and discharging power satisfy
  0 ≤ S j , h c h ≤ S j , m a x c h , 0 ≤ S j , h d i s ≤ S j , m a x d i s .
The state of charge evolves as
  SoC j , h + 1 = SoC j , h + η c S j , h c h − 1 η d S j , h d i s .
The complete feasibility region is
  SoC j , m i n ≤ SoC j , h ≤ SoC j , m a x .

Appendix B.2. Consumer Local Optimization

Each consumer solves
  m i n L i , h ∑ h = 1 H ( P h L i , h + θ i ( L i , h − L i , h 0 ) 2 − ϕ h ( L i , h 0 − L i , h ) ) .
First-order optimality yields
  ∂ J i ∂ L i , h = P h + 2 θ i L i , h − L i , h 0 + ϕ h = 0
which gives
  L i , h * = L i , h 0 − P h + ϕ h 2 θ i .

Appendix B.3. Prosumer Export Decision

Each prosumer maximizes
  U j = ∑ h = 1 H P h E j , h − η j S j , h c h + S j , h d i s
subject to export quantity
  E j , h = G j , h + S j , h d i s − S j , h c h − L j , h .

Appendix C. Smart Contract Workflow and Data Structures

This appendix describes the internal data structures and computational pipeline implemented in the Polygon PoS smart contract.

Core Data Structures

  • participants[a’]
Stores user role, generation capacity, storage capacity, meter ID, and registration status.
  • priceSchedule[d][h]
Stores day-ahead Stackelberg prices broadcast by MEMS.
  • schedule[a’][d][h]
Committed imports (consumers) or exports (prosumers).
  • measurement[a’][d][h]
Smart-meter readings for real-time power consumption or export.
  • settlement[a’][d]
Net payment or revenue after DR incentives and penalties.

Appendix D. Convergence Analysis

This appendix explains why the price update equations converge under the Stackelberg structure.

Appendix D.1. Price Update Rule

The MEMS updates the price iteratively as
  P h k + 1 = P h k − δ p ( ∑ j E j , h k − ∑ i L i , h k ) .
Define imbalance
  Δ h k = ∑ j E j , h k − ∑ i L i , h k .
The game is monotone because both consumer and prosumer best-response functions are affine. Thus, the price iteration converges whenever
  0 < δ p < 2 L m a x
where L m a x is the Lipschitz constant of the aggregate response.

Appendix D.2. Existence and Uniqueness

Because consumer costs are strongly convex and prosumer revenues are concave in their decision variables, the bilevel Stackelberg game reduces to a strict variational inequality, ensuring a unique fixed point.

Appendix E. Simulation Data and Parameter Sets

The following additional data were used in the experiments:

Appendix E.1. Data Sources

  • Household demand profiles: Pecan Street dataset
  • PV generation: Typical Meteorological Year (TMY3)
  • Battery: 4 kWh Li-ion, η c = 0.95 , η d = 0.90

Appendix E.2. Price Coefficients

  P h = α h L h + β h ,
with hourly coefficients calibrated from utility dynamic tariffs.

Appendix E.3. DR Parameters

  • Incentive rate: γ D R   =   0.12
  • Penalty rate: γ p e n   =   0.18
  • Required reduction: 10–15% of evening peak load
The proposed framework involves several parameters, including pricing coefficients, consumer discomfort factors, demand response incentive rates, and algorithm step sizes. These parameters are selected to ensure stable convergence and to reflect typical operating ranges reported in the demand response and microgrid pricing literature. Variations in pricing coefficients primarily influence the sensitivity of electricity prices to aggregate demand, while discomfort factors determine the extent of load flexibility offered by consumers. Demand response incentives control participation levels during DR events, and the algorithm step sizes affect convergence speed and numerical stability of the Stackelberg updates. Provided that these parameters remain within bounded ranges, the equilibrium solution remains well defined, with parameter variations mainly affecting transient behavior rather than overall system feasibility.

Appendix F. Smart Contract Deployment on Polygon PoS

For reproducibility, this appendix provides the deployment environment.

Appendix F.1. Tools

  • Remix IDE (Solidity 0.8.x)
  • MetaMask for key management
  • Polygon PoS mainnet (gas fee ≈ 0.03 USD)
  • Infura RPC endpoint
  • Chain ID = 137

Appendix F.2. Validation

All transactions, from price publication to schedule commitment and DR settlement, were executed successfully on-chain with negligible cost.

Appendix G. Blockchain Transactions

Figure A1. Average transaction duration for blockchain network users.
Figure A1. Average transaction duration for blockchain network users.
Energies 19 00643 g0a1
Figure A2. Smart Contract Deployed for P2P Energy Trading Using Remix Ethereum IDE and MetaMask wallet on Polygon PoS Mainnet.
Figure A2. Smart Contract Deployed for P2P Energy Trading Using Remix Ethereum IDE and MetaMask wallet on Polygon PoS Mainnet.
Energies 19 00643 g0a2

References

  1. Evens, M.; Ercoli, P.; Arteconi, A. Blockchain-Enabled Microgrids: Toward Peer-to-Peer Energy Trading and Flexible Demand Management. Energies 2023, 16, 6741. [Google Scholar] [CrossRef] [Scilit]
  2. Košt’ál, K.; Khilenko, V.; Hunák, M. Hierarchical Blockchain Energy Trading Platform and Microgrid Management Optimization. Energies 2024, 17, 1333. [Google Scholar] [CrossRef] [Scilit]
  3. Roald, L.A.; Pozo, D.; Papavasiliou, A.; Molzahn, D.K.; Kazempour, J.; Conejo, A. Power systems optimization under uncertainty: A review of methods and applications. Electr. Power Syst. Res. 2023, 214, 108725. [Google Scholar] [CrossRef] [Scilit]
  4. Nguyen, H.K.; Bin, S.J.; Han, Z. Distributed demand side management with energy storage in smart grid. IEEE Trans. Parallel Distrib. Syst. 2015, 26, 3346–3357. [Google Scholar]
  5. Long, C.; Wu, J.; Zhang, C.; Thomas, L.; Cheng, M.; Jenkins, N. Peer-to-peer energy trading in a community microgrid. In Proceedings of the 2017 IEEE Power & Energy Society General Meeting, Chicago, IL, USA, 16–20 July 2017. [Google Scholar]
  6. Erenoğlu, A.K.; Şengör, İ.; Erdinç, O.; Taşcıkaraoğlu, A.; Catalão, J.P.S. Optimal energy management system for microgrids considering energy storage, demand response and renewable power generation. Int. J. Electr. Power Energy Syst. 2022, 136, 107714. [Google Scholar] [CrossRef] [Scilit]
  7. Umar, A.; Kumar, D.; Ghose, T. Peer-to-Peer Energy Trading in a Self-Sustained Microgrid System Using Blockchain Technology. In Proceedings of the 2022 International Conference on IoT and Blockchain Technology (ICIBT), Ranchi, India, 6–8 May 2022; IEEE: Piscataway, NJ, USA, 2022; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
  8. Zhao, C.; Liu, Q.; Han, D.; Niu, P.; Wu, S. Decentralized energy trading framework with personalized pricing for energy community embedded with shared energy storage. Electr. Power Syst. Res. 2024, 235, 110562. [Google Scholar] [CrossRef] [Scilit]
  9. Kumar, R.S.; Raghav, L.P.; Raju, D.K.; Singh, A.R. Intelligent demand side management for optimal energy scheduling of grid connected microgrids. Appl. Energy 2021, 285, 116435. [Google Scholar] [CrossRef] [Scilit]
  10. Efanov, D.; Roschin, P. The all-pervasiveness of the blockchain technology. Procedia Comput. Sci. 2018, 123, 116–121. [Google Scholar] [CrossRef] [Scilit]
  11. Shahnaz, A.; Qamar, U. Using Blockchain for Electronic Health Records. IEEE Access 2019, 7, 147782–147795. [Google Scholar] [CrossRef] [Scilit]
  12. Agung, A.A.G.; Handayani, R. Blockchain for smart grid. J. King Saud Univ. Comput. Inf. Sci. 2022, 34, 666–675. [Google Scholar] [CrossRef] [Scilit]
  13. Zhang, C.; Wu, J. Peer-to-Peer energy trading in a Microgrid. Appl. Energy 2018, 220, 1–12. [Google Scholar] [CrossRef] [Scilit]
  14. Qu, D.; Li, J.; Yong, M. Real-time pricing for smart grid considering energy complementarity of a microgrid interacting with the large grid. Int. J. Electr. Power Energy Syst. 2021, 141, 108217. [Google Scholar] [CrossRef] [Scilit]
  15. Esfahani, M.M. A hierarchical blockchain-based electricity market framework for energy transactions in a security-constrained cluster of microgrids. Int. J. Electr. Power Energy Syst. 2022, 139, 108011. [Google Scholar] [CrossRef] [Scilit]
  16. Münsing, E.; Mather, J.; Moura, S. Blockchains for decentralized optimization of energy resources in microgrid networks. In Proceedings of the 2017 IEEE Conference on Control Technology and Applications (CCTA), Maui, HI, USA, 27–30 August 2017; pp. 2164–2171. [Google Scholar]
  17. Musleh, A.S.; Yao, G.; Muyeen, S. Blockchain Applications in Smart Grid–Review and Frameworks. IEEE Access 2019, 7, 86746–86757. [Google Scholar] [CrossRef] [Scilit]
  18. Danzi, P.; Angjelichinoski, M.; Stefanović, Č.; Popovski, P. Distributed proportional-fairness control in microgrids via blockchain smart contracts. In Proceedings of the 2017 IEEE International Conference on Smart Grid Communications (SmartGridComm), Dresden, Germany, 23–27 October 2017; pp. 45–51. [Google Scholar]
  19. Wen, Y.; Lu, F.; Liu, Y.; Huang, X. Attacks and countermeasures on blockchains: A survey from layering perspective. Comput. Netw. 2021, 191, 107978. [Google Scholar]
  20. Yang, X.; Wang, Y.; Zhang, Y.; Yao, W.; Wen, J. Impact analysis of cyber system in microgrids: Perspective from economy and reliability. Int. J. Electr. Power Energy Syst. 2021, 135, 107422. [Google Scholar]
  21. Guo, Z.; Ji, Z.; Wang, Q. Blockchain-enabled demand response scheme with individualized incentive pricing mode. Energies 2020, 13, 5213. [Google Scholar] [CrossRef] [Scilit]
  22. Al Moti, M.M.; Uddin, R.S.; Hai, A.; Bin Saleh, T.; Alam, G.R.; Hassan, M.M.; Hassan, R. Blockchain-based smart-grid Stackelberg model for electricity trading and price forecasting using reinforcement learning. Appl. Sci. 2022, 12, 5144. [Google Scholar] [CrossRef] [Scilit]
  23. Bokkisam, H.R.; Singh, S.; Acharya, R.M.; Selvan, M.P. Blockchain-based peer-to-peer transactive energy system for community microgrid with demand response management. CSEE J. Power Energy Syst. 2022, 8, 198–211. [Google Scholar] [CrossRef] [Scilit]
  24. Kumari, A.; Sukharamwala, U.C.; Tanwar, S.; Raboaca, M.S.; Alqahtani, F.; Tolba, A.; Sharma, R.; Aschilean, I.; Mihaltan, T.C. Blockchain-based peer-to-peer transactive energy management scheme for smart grid system. Sensors 2022, 22, 4826. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  25. Wang, L.; Jiang, S.; Shi, Y.; Du, X.; Xiao, Y.; Ma, Y.; Yi, X.; Zhang, Y.; Li, M. Blockchain-based dynamic energy management mode for distributed energy system with high penetration of renewable energy. Int. J. Electr. Power Energy Syst. 2023, 148, 108933. [Google Scholar] [CrossRef] [Scilit]
  26. Hussain, J.; Huang, Q.; Li, J.; Hussain, F.; Mirjat, B.A.; Zhang, Z.; Ahmed, S.A. A fully decentralized demand response and prosumer peer-to-peer trading for secure and efficient energy management of community microgrid. Energy 2024, 312, 133538. [Google Scholar] [CrossRef] [Scilit]
  27. Sepehrzad, R.; Langeroudi, A.S.G.; Al-Durra, A.; Anvari-Moghaddam, A.; Sadabadi, M.S. Demand response-based multi-layer peer-to-peer energy trading strategy for renewable-powered microgrids with electric vehicles. Energy 2025, 320, 135206. [Google Scholar] [CrossRef] [Scilit]
  28. Samadi, M.; Ruj, S.; Schriemer, H.; Erol-Kantarci, M. Secure and robust demand response using Stackelberg game model and energy blockchain. Sensors 2023, 23, 8352. [Google Scholar] [CrossRef] [Scilit]
  29. Li, J.; Li, T.; Dong, D. Demand response management of smart grid based on Stackelberg-evolutionary joint game. Sci. China Inf. Sci. 2023, 66, 182201. [Google Scholar] [CrossRef] [Scilit]
  30. Mendoza, F.G.; Konstantopoulos, G.; Bauso, D. Online pricing for demand-side management in a low-voltage resistive micro-grid via a Stackelberg game with incentive strategies. IET Smart Grid 2022, 5, 76–89. [Google Scholar] [CrossRef] [Scilit]
  31. Umar, A.; Kumar, D.; Ghose, T. Blockchain-based decentralized energy intra-trading with battery storage flexibility in a community microgrid system. Appl. Energy 2022, 322, 119544. [Google Scholar] [CrossRef] [Scilit]
  32. Foti, M.; Mavromatis, C.; Vavalis, M. Decentralized blockchain-based consensus for Optimal Power Flow solutions. Appl. Energy 2021, 283, 116100. [Google Scholar] [CrossRef] [Scilit]
  33. Khaqqi, K.N.; Sikorski, J.J.; Hadinoto, K.; Kraft, M. Incorporating seller/buyer reputation-based system in blockchain-enabled emission trading application. Appl. Energy 2018, 209, 8–19. [Google Scholar]
  34. Blockchain Consensus Mechanisms Beyond PoW and PoS. Available online: https://www.gemini.com/cryptopedia/blockchain-consensus-mechanism-types-of-algorithm (accessed on 15 April 2024).
  35. Yuan, Y.; Wang, F.-Y. Blockchain and cryptocurrencies: Model, techniques, and applications. IEEE Trans. Syst. Man Cybern. Syst. 2018, 48, 1421–1428. [Google Scholar] [CrossRef] [Scilit]
  36. Yang, J.; Paudel, A.; Dai, J.; Gooi, H.B. A mining-rewarding mechanism for peer-to-peer energy trading blockchain. In Proceedings of the 2021 IEEE PES Innovative Smart Grid Technologies-Asia (ISGT Asia), Brisbane, QLD, Australia, 5–8 December 2021; pp. 1–5. [Google Scholar] [CrossRef] [Scilit]
  37. Thomas, L.; Zhou, Y.; Long, C.; Wu, J.; Jenkins, N. A general form of smart contract for decentralized energy systems management. Nat. Energy 2019, 4, 140–149. [Google Scholar] [CrossRef] [Scilit]
  38. Pop, C.; Cioara, T.; Antal, M.; Anghel, I.; Salomie, I.; Bertoncini, M. Blockchain Based Decentralized Management of Demand Response Programs in Smart Energy Grids. Sensors 2018, 18, 162. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  39. Vieira, G.; Zhang, J. P2P energy trading in a microgrid leveraged by smart contracts. Renew. Sustain. Energy Rev. 2021, 143, 110900. [Google Scholar] [CrossRef] [Scilit]
  40. Alhussein, S.N.B.; Barzamini, R.; Ebrahimi, M.R.; Farahani, S.S.S.; Arabian, M.; Aliyu, A.M.; Sohani, B. Revolutionizing Demand Response Management: Empowering Consumers through Power Aggregator and Right of Flexibility. Energies 2024, 17, 1419. [Google Scholar] [CrossRef] [Scilit]
  41. Van Cutsem, O.; Dac, D.H.; Boudou, P.; Kayal, M. Cooperative energy management of a community of a smart buildings: A Blockchain approach. Int. J. Elect. Power Energy Syst. 2020, 117, 105643. [Google Scholar]
  42. Zhao, W.; Lv, J.; Yao, X.; Zhao, J.; Jin, Z.; Qiang, Y.; Che, Z.; Wei, C. Consortium Blockchain-Based Microgrid Market Transaction Research. Energies 2019, 12, 3812. [Google Scholar] [CrossRef] [Scilit]
  43. Gai, K.; Wu, Y.; Zhu, L.; Qiu, M.; Shen, M. Privacy-preserving energy trading using consortium blockchain in smart grid. IEEE Trans. Ind. Inform. 2019, 15, 3548–3558. [Google Scholar]
  44. Doostinia, M.; Beheshti, M.T.H.; Alavi, S.A.; Guerrero, J.M. Distributed event-triggered average consensus control strategy with fractional-order local controllers for DC microgrids. Electr. Power Syst. Res. 2022, 207, 107791. [Google Scholar] [CrossRef] [Scilit]
  45. Doostinia, M.; Beheshti, M.T.H.; Alavi, S.A.; Guerrero, J.M. Distributed control strategy for DC microgrids based on average consensus and fractional-order local controllers. IET Smart Grid 2021, 4, 549–560. [Google Scholar] [CrossRef] [Scilit]
  46. Bernstein, A.; Reyes-Chamorro, L.; Le Boudec, J.-Y.; Paolone, M. A composable method for real-time control of active distribution networks with explicit power setpoints. Part I: Framework. Electr. Power Syst. Res. 2015, 125, 254–264. [Google Scholar] [CrossRef] [Scilit]
  47. Baran, M.E.; Wu, F.F. Optimal capacitor placement on radial distribution systems. IEEE Trans. Power Deliv. 1989, 4, 725–734. [Google Scholar] [CrossRef] [Scilit]
  48. Zou, Y.; Xu, Y.; Feng, X.; Nguyen, H.D. Peer-to-Peer Transactive Energy Trading of a Reconfigurable Multi-Energy Network. IEEE Trans. Smart Grid 2023, 14, 2236–2249. [Google Scholar] [CrossRef] [Scilit]
  49. Khorasany, M.; Gazafroudi, A.S.; Razzaghi, R.; Morstyn, T.; Shafie-Khah, M. A framework for participation of prosumers in peer-to-peer energy trading and flexibility markets. Appl. Energy 2022, 314, 118907. [Google Scholar] [CrossRef] [Scilit]
  50. Khorasany, M.; Najafi-Ghalelou, A.; Razzaghi, R. A Framework for Joint Scheduling and Power Trading of Prosumers in Transactive Markets. IEEE Trans. Sustain. Energy 2021, 12, 955–965. [Google Scholar] [CrossRef] [Scilit]
  51. Wang, Y.; Yang, Q.; Zhou, Y.; Zheng, Y. A risk-averse day-ahead bidding strategy of transactive energy sharing microgrids with data-driven chance constraints. Appl. Energy 2024, 353, 122093. [Google Scholar] [CrossRef] [Scilit]
  52. Che, Y.; Yang, J.; Zhou, Y.; Zhao, Y.; He, W.; Wu, J. Demand Response from the Control of Aggregated Inverter Air Conditioners. IEEE Access 2019, 7, 88163–88173. [Google Scholar] [CrossRef] [Scilit]
  53. Liu, W.-J.; Chiu, W.-Y.; Hua, W. Blockchain-enabled renewable energy certificate trading: A secure and privacy-preserving approach. Energy 2024, 290, 130110. [Google Scholar] [CrossRef] [Scilit]
  54. Umar, A.; Kumar, D.; Ghose, T. Peer-to-Peer Decentralized Community Energy Management System Using Blockchain Technology. In Proceedings of the 2022 IEEE 1st Industrial Electronics Society Annual On-Line Conference (ONCON), Kharagpur, India, 9–11 December 2022; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
  55. Pecan Street Data Port. Available online: https://www.pecanstreet.org/dataport/ (accessed on 1 December 2023).
  56. Umar, A.; Kumar, D.; Ghose, T.; Alghamdi, T.A.H.; Abdelaziz, A.Y. Decentralized Community Energy Management: Enhancing Demand Response Through Smart Contracts in a Blockchain Network. IEEE Access 2024, 12, 80781–80798. [Google Scholar] [CrossRef] [Scilit]
  57. Lüth, A.; Zepter, J.M.; del Granado, P.C.; Egging, R. Local electricity market designs for P2P trading: The role of battery flexibility. Appl. Energy 2018, 229, 1233–1243. [Google Scholar]
Figure 1. Microgrid blockchain framework: Integrating the participants, game theoretic pricing, smart contracts, and the energy transaction model.
Figure 1. Microgrid blockchain framework: Integrating the participants, game theoretic pricing, smart contracts, and the energy transaction model.
Energies 19 00643 g001
Figure 2. Microgrid System Model for Energy Scheduling.
Figure 2. Microgrid System Model for Energy Scheduling.
Energies 19 00643 g002
Figure 3. P2P Energy Transaction Flowchart Employing Blockchain Smart Contract Features.
Figure 3. P2P Energy Transaction Flowchart Employing Blockchain Smart Contract Features.
Energies 19 00643 g003
Figure 4. Workflow of blockchain-integrated Stackelberg-based microgrid energy management system.
Figure 4. Workflow of blockchain-integrated Stackelberg-based microgrid energy management system.
Energies 19 00643 g004
Figure 5. Networked community microgrid model.
Figure 5. Networked community microgrid model.
Energies 19 00643 g005
Figure 6. Battery Discharging Logic for P2P Energy Transaction [56].
Figure 6. Battery Discharging Logic for P2P Energy Transaction [56].
Energies 19 00643 g006
Figure 7. Microgrid Hourly Load Profile.
Figure 7. Microgrid Hourly Load Profile.
Energies 19 00643 g007
Figure 8. Microgrid Total DER Generations.
Figure 8. Microgrid Total DER Generations.
Energies 19 00643 g008
Figure 9. Microgrid Total Battery Charging Level Available for P2P Energy Trading.
Figure 9. Microgrid Total Battery Charging Level Available for P2P Energy Trading.
Energies 19 00643 g009
Figure 10. Microgrid Total Power Imported from the Utility Grid.
Figure 10. Microgrid Total Power Imported from the Utility Grid.
Energies 19 00643 g010
Figure 11. Hourly Stackelberg Equilibrium Price (λ*(h)).
Figure 11. Hourly Stackelberg Equilibrium Price (λ*(h)).
Energies 19 00643 g011
Figure 12. Peer-to-peer Energy Exchange Between Battery-Powered Houses.
Figure 12. Peer-to-peer Energy Exchange Between Battery-Powered Houses.
Energies 19 00643 g012
Figure 13. The total amount of P2P energy trading volume using batteries.
Figure 13. The total amount of P2P energy trading volume using batteries.
Energies 19 00643 g013
Figure 14. Total Load Scheduling with and without DSM.
Figure 14. Total Load Scheduling with and without DSM.
Energies 19 00643 g014
Figure 15. Total Cost comparison with and without DSM.
Figure 15. Total Cost comparison with and without DSM.
Energies 19 00643 g015
Table 1. A comparison between the proposed work and current frameworks.
Table 1. A comparison between the proposed work and current frameworks.
PaperFocusPricing/Game ModelBlockchain & ConsensusDR/DSM SupportP2P Trading Support
[21]Blockchain-enabled DR with individualized incentives between retailer/aggregator and usersStackelberg game between retailer (leader) and users (followers)Consortium/permissioned energy blockchain with smart contracts; practical Byzantine fault tolerant (PBFT-type) consensus rather than public PoWYes—detailed incentive-based DR with individualized pricingNo—users transact with the retailer, not a P2P market
[22]Stackelberg pricing and RL-based forecasting in a blockchain-enabled smart gridStackelberg leader–follower between grid operator and prosumers, with RL to learn responsesEthereum-style blockchain with smart contracts; exact consensus (PoW vs. PoS) not analysed explicitlyPartial—price-based DR; focus on optimal tariffs rather than full DR event frameworkNo—interaction is mainly utility ↔ users, not a prosumer-to-prosumer market
[23]Blockchain P2P transactive energy with DR in a community microgridAuction-based market clearing; no Stackelberg structureBlockchain platform with smart contracts; paper focuses on market clearing and DR rather than consensus detailsYes—explicit DR management integrated with P2P transactive energyYes—P2P prosumer–consumer trading in a community microgrid
[24]P2P energy management using blockchain in smart gridOptimization-based P2P transaction scheduling; no Stackelberg formulationEthereum smart contracts; consensus mechanism (PoW/PoS) not the focus of the paperLimited DSM/DR—emphasizes secure P2P trading more than DR program designYes—P2P prosumer–consumer trading
[25]Dynamic energy management for DES with an energy blockchainNo Stackelberg; EMS-oriented optimization plus custom consensusCustom energy blockchain with Proof of Energy Contribution (PoEC) consensus and optimized SM2 encryption tailored to DESConceptual link to DR, but no explicit DR program or DR events are modelledYes—the system includes a P2P electricity trading module among prosumers in the DES
[26]Fully decentralized DR and prosumer P2P trading in a community microgridMultiple non-cooperative dynamic games with Nash equilibrium; no StackelbergNo blockchain layer—decentralization is algorithmic (multi-agent games), not via DLTYes—detailed DR program combining ToU pricing and incentive-based biddingYes—prosumer P2P trading within the community microgrid
[27]DR-based multi-layer P2P trading among microgrids and EVsGame-theoretic/multi-objective probabilistic framework; not StackelbergNo blockchain layer—focuses on market layers and uncertainty, not DLTYes—DR is central (pricing + DR-based scheduling under uncertainty)Yes—multi-layer P2P trading among agents and EVs
[28]Secure DR with Stackelberg game and energy blockchainMixed-strategy Stackelberg game between a control agent (leader) and customers (followers)“Energy blockchain” architecture with smart contracts and a tailored consensus algorithm; exact consensus name not central to paperYes—robust demand response with stochastic DR modelNo—customers trade with utility/DSO; no direct P2P market
[29]DR management using Stackelberg evolutionary game in smart grid/multi-microgrid settingStackelberg + evolutionary game among aggregators and usersNo blockchain—focuses on game-theoretic DRYes—DR/DSM is the coreNo—no explicit P2P market
[30]Online DSM pricing and tariff design for LV gridsStackelberg-type or bilevel pricing between DSO/aggregator and consumersNo blockchainYes—DSM/DR through pricingNo—classical utility–consumer structure
[31]Privacy-aware DR framework using blockchain; Sybil-resistant validator selection and security metricsSecurity/mechanism-design oriented; not Stackelberg (focus on DR events, penalties, and validator incentives)Hybrid PoS with reputation and Sybil-resistance (as per your framework); energy blockchain tailored to MEMSYes—DR event activation, incentive and penalty logic, DSM performance metricsThis paper emphasizes DR & security rather than full market-clearing for P2P energy trades
Proposed Work Real-time price regulation and DR in a P2P microgrid using Stackelberg + blockchain
(Combined Stackelberg price regulation, real-time DR, day-ahead commitments, P2P trading, Polygon PoS)
Full Stackelberg leader–follower game between MEMS (leader) and participants (followers) for price and DR signalsPolygon Proof of Stake mainnet; complete set of smart contracts deployed with on-chain DR, settlements, validator incentivesYes—full DR: real-time DR events, day-ahead commitments, incentive and penalty logic encoded on-chainYes—full P2P: prosumer-to-consumer trading plus MEMS coordination
Table 2. Distribution Line Parameters for the 10-House Community Network Microgrid. [LV radial feeder, V base = 0.4   kV , V min = 0.95 pu, V max = 1.05 pu. Thermal limit per line: S a b max = 60   kVA , r = 0.40   Ω / km ,   x = 0.08   Ω / km , so r a b = r l a b , x a b = x l a b ].
Table 2. Distribution Line Parameters for the 10-House Community Network Microgrid. [LV radial feeder, V base = 0.4   kV , V min = 0.95 pu, V max = 1.05 pu. Thermal limit per line: S a b max = 60   kVA , r = 0.40   Ω / km ,   x = 0.08   Ω / km , so r a b = r l a b , x a b = x l a b ].
Line (a, b) Length   l a b (km) r a b (Ω) x a b (Ω) S a b m a x (kVA)
(0,1)0.200.0800.01660
(1,2)0.150.0600.01260
(2,3)0.150.0600.01260
(2,4)0.100.0400.00860
(4,5)0.100.0400.00860
(3,6)0.200.0800.01660
(6,7)0.100.0400.00860
(6,8)0.150.0600.01260
(8,9)0.100.0400.00860
(9,10)0.100.0400.00860
Table 3. Electrical Validation Results over 24-h Operation.
Table 3. Electrical Validation Results over 24-h Operation.
MetricDescriptionValueOperational Limit
Minimum bus voltageLowest observed voltage magnitude0.999488 pu (Bus 1, Hour 19)≥0.95 pu
Maximum bus voltageHighest observed voltage magnitude1.002214 pu (Bus 10, Hour 7)≤1.05 pu
Maximum line loadingHighest line utilization22.81% (Line 2–3, Hour 7)≤100%
Total daily network lossAggregate feeder loss over 24 h0.5788 kWh—
Peak hourly lossMaximum hourly feeder loss0.0256 kW—
Table 4. Types of appliances and consumption profile.
Table 4. Types of appliances and consumption profile.
CategoryElectrical ApplianceConsumption (kW)Willingness to Shift Load
Non-shiftableAir conditioner 31
Heating 41
Ceiling fan 0.11
Refrigerator 0.61
Lights 0.021
Television0.21
PC 0.121
Monitor0.151
Laptop0.071
Coffee maker0.61
Microwave oven1.31
ShiftableDishwasher1.20.6
Vacuum cleaner0.220.5
Washing machine0.30.2
Clothes dryer2.20.5
Table 5. Comparison of Microgrid Financial Data Prior to and Following Demand Response Program Implementation Using Stackelberg Game Results.
Table 5. Comparison of Microgrid Financial Data Prior to and Following Demand Response Program Implementation Using Stackelberg Game Results.
MetricBefore Stackelberg
Optimization
After Stackelberg
Optimization
Improvement
Prosumer Energy Sold (kWh)19.523+3.50 (+18.0%)
Consumer Energy Purchased (kWh)2522−3.00 (−12.0%)
Total Export from Prosumers (kWh)31.234.9+3.70 (+11.9%)
Total Import from Grid (kWh)12.810.1−2.70 (−21.1%)
Peak Demand (kW)4.213.67−0.54 (−12.8%)
Peak-to-Average Ratio (PAR)1.781.52−0.26 (−14.6%)
Consumer Cost (normalized)10.88−12.0%
Prosumer Revenue (normalized)11.1111.00%
System Operational Cost (USD equivalent)19.9317.94−1.99 (−10.0%)
Total Daily System Benefit––6.99
Table 6. Blockchain Performance Metrics of the Proposed Framework.
Table 6. Blockchain Performance Metrics of the Proposed Framework.
MetricValueDescription/Significance
Transaction Confirmation Time2.01–2.15 sTime required for a transaction (DR event, price update, settlement) to be finalized on Polygon PoS. Suitable for near real-time microgrid operations.
Gas Fee per Transaction0.0001–0.0003 USD (≈0.00006–0.00015 MATIC)Extremely low cost ensures scalability of DR updates, P2P trades, and settlement without economic burden.
Smart Contract Execution Success Rate100% (500/500 tests)Shows reliability of on-chain logic under repeated DR signals, incentives, penalties, and P2P trades.
Throughput Capacity of Polygon PoS7000+ TPSProvides ample headroom for dense microgrid communication events.
DR Event Trigger Latency1.20 sTime from MEMS signal broadcast to blockchain event confirmation.
Settlement Latency (Energy Trade)2.10 s averageTime for payment settlement triggered by smart meter commit.
On-Chain Storage Cost<0.002 USD per 1 kB state updateVery low cost due to compressed event logs and minimal storage footprint.
Security AssuranceECDSA + PoS finalityEnsures tamper-proof settlement with validator-backed consensus.
Finality Window<3 sGuarantees irreversible commitment of all trades and DR actions.
Off-Chain to On-Chain Sync Error Rate0% packet loss under tested loadsConfirms robust integration of smart meter data → MEMS → blockchain.
Table 7. Comparative Evaluation of Microgrid Energy Management Approaches.
Table 7. Comparative Evaluation of Microgrid Energy Management Approaches.
MethodCoordination TypeDR SupportP2P TradingReal-Time PricingScalabilityImplementation Feasibility
Centralized DRCentral controllerYes (price-based)NoLimitedLow–MediumHigh computational burden
Classical OPF-based ControlCentralizedImplicit (via constraints)NoNoLowRequires full network model
Conventional P2P TradingDecentralizedLimited/heuristicYesStatic or auction-basedMediumOften simulation-only
Stackelberg-based DSM (No Blockchain)Semi-distributedYesLimitedYesMediumLacks automated settlement
Proposed FrameworkDistributed (Leader–Follower)Yes (incentive + penalty)YesReal-time adaptiveHighOn-chain executable
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Umar, A.; Jamwal, P.K.; Kumar, D.; Gupta, N.; Gali, V.; Kumar, A. Blockchain-Integrated Stackelberg Model for Real-Time Price Regulation and Demand-Side Optimization in Microgrids. Energies 2026, 19, 643. https://doi.org/10.3390/en19030643

AMA Style

Umar A, Jamwal PK, Kumar D, Gupta N, Gali V, Kumar A. Blockchain-Integrated Stackelberg Model for Real-Time Price Regulation and Demand-Side Optimization in Microgrids. Energies. 2026; 19(3):643. https://doi.org/10.3390/en19030643

Chicago/Turabian Style

Umar, Abdullah, Prashant Kumar Jamwal, Deepak Kumar, Nitin Gupta, Vijayakumar Gali, and Ajay Kumar. 2026. "Blockchain-Integrated Stackelberg Model for Real-Time Price Regulation and Demand-Side Optimization in Microgrids" Energies 19, no. 3: 643. https://doi.org/10.3390/en19030643

APA Style

Umar, A., Jamwal, P. K., Kumar, D., Gupta, N., Gali, V., & Kumar, A. (2026). Blockchain-Integrated Stackelberg Model for Real-Time Price Regulation and Demand-Side Optimization in Microgrids. Energies, 19(3), 643. https://doi.org/10.3390/en19030643

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop