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
generates renewable power
at hour
, stores energy in a local battery
, and consumes load
. Each consumer
has a demand
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
for every time slot
. 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
be
Each prosumer uses a battery energy storage system characterized by charge and discharge power
and
(both nonnegative). The State of Charge (SoC) at time
evolves as
where
and
are charging and discharging efficiencies.
The SoC is bounded as
and the operational power limits are
At the end of the scheduling horizon
, the SoC is restored to its initial value:
(C) Aggregated Load and Grid Pricing Function.
The total load on the microgrid during the time slot
is
The MEMS determines the marginal grid price using a quadratic pricing function that captures time-of-use variation and dependency on total demand [
31]:
where
and
are the grid coefficients varying with time and renewable intermittency.
The total grid cost of supplying load
during hour
is
(D) Inconvenience Cost and Incentive Formulation.
Each consumer can adjust or shift part of its baseline load profile .
The inconvenience cost associated with this load shifting is modeled as
where
denotes the inconvenience factor. Higher
values reflect reduced flexibility and increased discomfort.
During a Demand Response (DR) event, consumers receive an incentive proportional to their load reduction:
where
is the DR incentive coefficient broadcast by the MEMS. The net consumer cost is then
(E) Prosumers’ Revenue Function.
Each prosumer sells its surplus energy
to peers or the grid, defined as
A positive denotes export, and negative indicates import.
The revenue function for prosumer
is
where
is the degradation cost coefficient of the battery.
The daily prosumer profit is then
(F) MEMS Objective and Power Balance Constraint.
The MEMS aims to minimize the total system cost, including energy purchase, user inconvenience, and grid cost:
subject to:
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 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 , 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:
Each prosumer maximizes its utility:
The MEMS acts as the leader that updates
and
iteratively to balance total supply and demand:
where
and
are step-size parameters controlling convergence.
The process converges to a Nash–Stackelberg equilibrium where:
At equilibrium, the price reflects the marginal cost of supply, and all users reach their optimal schedules , .
(H) Convergence and Properties.
Because the individual cost functions and are strictly convex (quadratic) and the pricing function 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 , where 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
and
and records the settled prices
on the blockchain. Smart contracts execute payment settlement as:
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 ; baseline loads ; generation Battery parameters Pricing coefficients Inconvenience factors Degradation factors Step sizes Tolerance
Outputs:
Algorithm:
Set .
Initialize .
- 2.
Broadcast: MEMS sends to all users.
- 3.
Consumer update (parallel for all ): Solve
subject to device limits.
Return .
- 4.
Prosumer update (parallel for all ):
Solve
subject to
Return .
- 5.
Aggregation at MEMS: - 6.
Price update: - 7.
Incentive update: - 8.
Convergence test: If for all h:
stop.
Else set and return to Step 2.
Final Outputs
|
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
, the optimized market outcomes are mapped to nodal power injections. The net active power injection at bus
is defined as
Here, denotes the net power exported by the prosumer , as defined in Equation (12), and represents the scheduled electricity demand of consumer . Positive values of indicate net power injection into the distribution network, while negative values represent net power consumption.
Reactive power injections 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
, the squared voltage magnitude relationship is expressed [
47] as
where
and
are the voltage magnitudes at buses
and
, respectively, and
and
denote the active and reactive power flows on line
at time slot
. The parameters
and
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 pu.
Electrical Operating Constraints:
The following electrical constraints are evaluated for all buses, lines, and time slots:
where
and
denote the minimum and maximum allowable voltage magnitudes, and
is the apparent power rating of line
.
Loss Modeling:
Real power losses on each distribution line are approximated as
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 Day index Participants Stackelberg prices Consumer optimal loads Prosumer optimal exports
Output: Step 1. Contract Initialization - 1.1
- 1.2
- 1.3
Initialize mappings Step 2. Participant Registration For any address : - 2.1
If , reject. - 2.2
Otherwise set Step 3. Day Initialization If
, then Step 4. Price-Schedule Publication For all : Step 5. Submission of Optimal Schedules For a consumer with address :
For a prosumer with address :
Smart contract enforces:
Consumer nonnegativity: Prosumer feasibility: Store committed schedule:
|
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 , and for prosumers, it is their optimal export . 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 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
, 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
with the measured value. The difference, if positive, represents a valid load reduction
. Summing across all affected hours yields each user’s total DR contribution
, while summing across all consumers yields the system-level reduction
.
| Algorithm 3. Real-Time DR Execution, Measurement, and Settlement |
Given: Output: DR reductions System reduction Consumer payments Prosumer revenues Step 1. DR Event Activation Set Step 2. Real-Time Measurement Logging For each address and slot : Step 3. DR Reduction Calculation For each consumer :
- 3.1
Slot-wise reduction: - 3.2
Total consumer reduction: - 3.3
System reduction: - 3.4
DR success factor: Step 4. Consumer Settlement For each consumer : - 4.1
Energy cost per slot: - 4.2
DR incentive (only for ): - 4.3
Penalty for deviation from committed schedule: - 4.4
Net daily payment: Store: Step 5. Prosumer Settlement For each prosumer : - 5.1
Revenue per slot: - 5.2
Penalty for under-delivery: - 5.3
Net daily revenue: Store:
|
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 is applied. Otherwise, incentives are proportionally scaled by the ratio , ensuring fairness and preventing overpayment during partial fulfilment. Settlement is then performed individually for every participant. Consumers are charged an energy cost 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 , 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.