Next Article in Journal
Partial Stability of Linear Hybrid Discrete–Continuous Itô Systems with Aftereffect
Previous Article in Journal
Generalized Inference for Mediation Analysis
Previous Article in Special Issue
Efficient and Secure Traffic Scheduling Based on Private Sketch
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Decentralized Energy Swapping for Sustainable Wireless Sensor Networks Using Blockchain Technology

1
Department of Computer Science, University of Sahiwal, Sahiwal 57000, Pakistan
2
Artificial Intelligence and Sensing Technologies (AIST) Research Center, University of Tabuk, Tabuk 71491, Saudi Arabia
3
Department of Computer Science, University of Okara, Okara 56300, Pakistan
4
Faculty of Computers and Information Technology, University of Tabuk, Tabuk 71491, Saudi Arabia
*
Authors to whom correspondence should be addressed.
Mathematics 2025, 13(3), 395; https://doi.org/10.3390/math13030395
Submission received: 28 November 2024 / Revised: 13 January 2025 / Accepted: 22 January 2025 / Published: 25 January 2025

Abstract

:
Wireless sensor networks deployed in energy-constrained environments face critical challenges relating to sustainability and protection. This paper introduces an innovative blockchain-powered safe energy-swapping protocol that enables sensor nodes to voluntarily and securely trade excess energy, optimizing usage and prolonging lifespan. Unlike traditional centralized management schemes, the proposed approach leverages blockchain technology to generate an open, immutable ledger for transactions, guaranteeing integrity, visibility, and resistance to manipulation. Employing smart contracts and a lightweight Proof-of-Stake consensus mechanism, computational and power costs are minimized, making it suitable for WSNs with limited assets. The system is built using NS-3 to simulate node behavior, energy usage, and network dynamics, while Python manages the blockchain architecture, cryptographic security, and trading algorithms. Sensor nodes checked their power levels and broadcast requests when energy fell under a predefined threshold. Neighboring nodes with surplus power responded with offers, and intelligent contracts facilitated secure exchanges recorded on the blockchain. The Proof-of-Stake-based consensus process ensured efficient and secure validation of transactions without the energy-intensive need for Proof-of-Work schemes. The simulation results indicated that the proposed approach reduces wastage and significantly boosts network resilience by allowing nodes to remain operational longer. A 20% increase in lifespan is observed compared to traditional methods while maintaining low communication overhead and ensuring secure, tamper-proof trading of energy. This solution provides a scalable, safe, and energy-efficient answer for next-generation WSNs, especially in applications like smart cities, precision agriculture, and environmental monitoring, where autonomy of energy is paramount.

1. Introduction

In wireless sensor networks (WSNs), energy constraints have always been an intrinsic problem because the sensor nodes usually operate with finite battery power. This is because the network works 24/7, and long-term energy management must be conducted to ensure that nodes do not fail prematurely, causing a disruption in service and compromised data integrity. This issue is obviously an urgent problem, for purposes such as environmental monitoring and precision agriculture, especially for applications in harsh or remote locations in which the battery cannot be easily replaced [1]. Existing flow-based protocols for energy conservation mainly concentrate on passive redundancy, which, after a certain fraction, may have no valid data to send or receive in the network. Hence, a vast proportion of nodes switch off into sleeping mode at any position. Although there are a significant number of sections [2], research and approaches still need to be developed to effectively determine how additional capacity can benefit from renewable power sources traditionally parsing through alternative routes by minimizing node activity reasons with active links, orchestrated recycling schemes, etc. On the other hand, promising alternatives have emerged that let nodes draw energy from surrounding sources (e.g., solar, RF signals and vibrations) owing to recent advances in energy harvesting technologies [3].
Diverse energy sources (solar, RF, etc.) for complementary harvesting of solar and thermal energies have been successfully employed to extend the lifespan of sensor nodes through hybrid generators that change sources based on availability [4]. In addition, advances in piezoelectric energy harvesting have accomplished huge improvements in capturing mechanical vibrations from their environmental settings, making WSNs self-sufficient as they can be deployed on roadways or industrial places [5]. However, the energy management system of WSNs still needs to improve efficacies, primarily due to the centralized control where these paths become susceptible to points of failure or congestion. To fortify grid strength and scalability, the next challenge is transitioning towards decentralized energy management. To address this using blockchain technology, blockchain provides a decentralized and secure P2P network that aims to enable human beings to have automated operations (energy management) via intelligent contracts, which are distributed consensus [6]. The blockchain allows for sensor nodes, in a decentralized way with no central authority involved, to trade surplus energy for that of their neighbors automatically, and so uniformly distribute the generated power load across all sensor node locations [7]. This can significantly improve both the longevity of the network and provide a perpetually present capability in ubiquitous energy-limited environments [8].
Inspired by these directions, this paper introduces the blockchain-based secure energy swapping protocol for self-sustainable WSNs that leverage energy harvesting and branch with blockchain to formalize a secure decentralized architecture suitable for energy management in these IoT settings. This system enables nodes to automatically exchange excess energy with other neighboring ones over blockchain transactions. The WSN environment is simulated using NS3.NS, modelling the node behavior together with energy consumption as healthy as network dynamics comes first, whereas Python, on the other hand, controls blockchain architecture and energy trading algorithms [9]. To reduce computational and energy burden, a Proof-of-Stake (PoS) consensus algorithm is employed, which is appropriately designed for resource-constrained WSNs. Leveraging node energy contributions to validate transactions, PoS is categorically exemplified in an energy-trading scenario that stays closer to the spirit of conservation and security than the traditional Proof-of-Work (PoW) method that wastes a tremendous amount of power [10]. The addition of the blockchain with energy-swapping protocols not only strengthens security but also enhances scalability, and it is now feasible to monitor large-scale WSN deployments in terms of managing energies [11]. In parallel, to gain nearly optimal energy statistics, the system model and its design parameters are extended to include state-of-the-art solar as well as hybrid RF–solar sourced energy models in earlier works on proposed GEN (Global Energy-aware Node), which achieves further optimization from gaining near-optimal availability and collector efficiency [12,13]. Energy trades between nodes are automatically carried out using blockchain-based intelligent contracts when certain conditions are linked to the energy levels of a node, such as the lower bound condition when an individual or group has her/his/its battery less than some predetermined threshold [13]. This ensures self-operation of the node all the time regardless of human presence, which makes the system highly autonomous and scalable, and ensuring it does not need manual intervention. The originality of this work is mainly reflected in the seamless incorporation of blockchain into the energy management and energy harvesting practice for WSNs, thereby providing an efficient method to ensure a trustworthy decentralized service towards sustainable sensor networks. While previous work has concentrated on the use of blockchain in WSNs for security [14], this study focuses on how blockchain can help maximize the efficient exploitation of energy resources. The scalability of the system, along with PoS efficiency, helps sensor nodes trade energy securely and autonomously for an extended network lifetime [15].
This study complements the literature by presenting a system that applies and combines blockchain technology with energy harvesting, resulting in an efficient, secure, and autonomous WSN. The concept is highly scalable and can be used for applications in the domains of smart cities and environmental monitoring, among other mission-critical scenarios that require clean power autonomy [15,16,17]. Experiments have shown that this system can improve network reliability by prolonging the lifetime of nodes using efficient energy redistribution and a reliable distributed control method [18,19,20]. The proposed study adds a new horizon of energy swapping for sustainable WSNs.

Contribution

The novel contribution of the article is listed below:
  • The innovative decentralized blockchain protocol enabling autonomous energy exchanges is introduced between sensor nodes, significantly enhancing the sustainability of wireless sensor systems through smart contracts and an efficient Proof-of-Stake verification process with a mathematical approach.
  • A hybrid energy harvesting system that integrates multiple renewable sources, including solar, radio frequency, and piezoelectric power, alongside blockchain-enabled redistribution is proposed to optimize usage and dynamically extend functionality in resource-limited settings.
  • It is observed that a 20% increase in operating time will be achieved by allowing sensor devices to monitor autonomously and trade power reserves, preventing depletion and hotspots by ensuring continuous, energy-efficient performance over longer durations with proof of mathematics constraints.
  • A scalable, efficient, and secure blockchain solution adapted for applications with the emerging Internet of Things, including intelligent urban infrastructures involving environmental monitoring, in which self-sufficiency of energy resources and tamper-proof decentralized oversight are mission critical.
The rest of this paper is structured in the following manner. Section 2 presents a detailed survey of the state-of-the-art in blockchain-based energy management and WSNs with application to decentralized architecture, energy harvesting, and secure energy trading mechanisms. In Section 3, the system and theoretical analysis and energy-redirection framework are introduced, followed by a description of blockchain-based smart contracts and a lightweight Proof-of-Stake (PoS) consensus mechanism enabling secure, low-power energy transactions between sensor nodes. In Section 4, dataset description and pre-processing with specific designs of hybrid EH and energy trading mechanisms are elaborated, and solar, RF, and piezoelectric energies are incorporated with autonomous energy swapping protocols to exchange energy freely. The proposed model is discussed in Section 5. The simulation setup and results that demonstrate the effectiveness of the proposed model regarding energy efficiency, network lifetime, and scalability are discussed in Section 6. This section also includes a comparison with existing models. Lastly, Section 7 provides conclusive remarks summarizing the findings and contributions and offering directions for future work.

2. Related Work

Blockchain has been applied in wireless sensor networks (WSNs) with energy-efficient protocols, making this an active research area to overcome the limitations of a decentralized and secure environment within these networks. Many researchers have put forward solutions to enhance the performance of WSNs through blockchain-based designs, optimization algorithms, and energy-aware routing protocols.
Moreover, in [21] proposed a blockchain-based multi-hop routing scheme for WSNs to offer inexpensive, self-organizing distributed storage. They developed a trust based on the blockchain to extend the network’s lifetime through energy trading in the blockchain. In [22], the abovementioned problem of hotspots in WSN was solved by introducing an Energy-Aware Distributed Sink Algorithm (EADSA). The study focuses on energy distribution between nodes, which plays a vital role in the proposed solution protocol for blockchain-based energy swapping. The proposed model prolongs the lifecycle of sensor nodes and reduces communication overhead using a decentralized energy exchange. In another study, ref. [23] introduced smart grid data secured by a blockchain for WSNs. Their attention has been concentrated on decentralized data securing, which is a positive thing for blockchain solutions in WSNs. Therefore, the proposed work extends this scope and employs blockchain to provide enhanced security as well as facilitate secure energy transactions among various nodes in resource-constrained settings. In [24] proposed an improved energy-optimized LEACH protocol for WSNs targeted at efficient data sending. Their work primarily focuses on data transfer; however, an energy-optimizing component is integrated with our protocol to improve energy efficiency through decentralized local and regional-level energy trading, aided by blockchain technology. In [25], related to traffic agents between WSNs IoT-like system, Draz et al. scrutinized the effects of hotspot on IoT and allowed for WSN tidal flex. Because the IoT is not part of this work, it is one of the few that identifies energy depletion due to network congestion, an issue that blockchain-based sensor-to-sensor protocol addresses by redistributing energy among sensor nodes reasonably evenly. In [26] introduced a two-stage scale-free topology evolution model to enhance the energy efficiency and robustness of wireless sensor networks. This prior approach deploys mechanisms for clustering to reduce energy consumption, which is complementary to the proposed work, ensuring scalable and decentralized management of the excess energy interchange between nodes by adding blockchain to each node. Table 1 summarizes the latest work in this domain.
The underwater music source localization work [29] proposed an energy-efficient routing protocol for underwater wireless sensor networks (UWSNs). With its challenging edge-of-grid energy optimization focus, it is aligned with the goal of optimizing energy usage in harsh environments through green and secure blockchain-based energy trading. In [30] introduced a genetic algorithm approach for energy conservation in wireless sensor networks. This study extends it by embedding blockchain technology, which is suitable for realizing secure energy redistribution for efficient use of power and minimizing overall power consumption with decentralized control in the network. Authors surveyed energy-efficient algorithms used for routing underwater [27]. Their work provides a basis to enhance energy optimization in WSNs by introducing blockchain to enable autonomous trading of energy among nodes and, therefore, prolonging the network lifetime. In [31] proposed an energy-optimal technique for IoT-driven WSNs. Their work focuses on the results obtained in two studies which converged while designing the protocol: energy-efficient communication is relevant for IoT networks, and blockchain-based decentralized energy transactions may foster long-lasting network operation by preventing unnecessary waste of resources. In [32] studied energy-balanced routing in WSNs using Particle Swarm Optimization (PSO) with mutation-based operators.
The proposed solution is very close to a blockchain-enabled secure energy trading, in which the optimization technique is developed to optimize the balancing of the sensor nodes with relevant levels. In [33] present the hotspot algorithm to balance energy routing in WSN with subnets. While proposed work efforts at Masurium focus on securing hotspots from energy depletion (by utilizing nodes to trade with each other), the work by Byte Ball is solely focused on solving an issue of hot spots in resolutions due to massive power consumption. The authors of [34] proposed a Watchman-based Data Packet Forwarding Algorithm for Underwater WSNs that focuses on the energy efficiency of data forwarding. The proposed solution automates energy trading between nodes using blockchain to achieve increased efficiency in the supply of electrical power, leading to a longer-lasting network.
The algorithm approach used for cluster head selection in WSN is as follows [35] presented an improved energy-efficient Sparrow Search Algorithm to determine cluster head selection. This commitment to energy efficiency via intelligent selection mirrors the proposed approach with KALI, the blockchain-based battery-swapping protocol that allows nodes on a network generating excess power (battery far from complete) and in need of external storage or refinement to dynamically proportion/donate electricity credit to each other. One such relevant research by [36] introduced a Genetically derived Optimization Algorithm with an emphasis on pruning and validation techniques to improve the energy efficiency in WSN. The proposed study is complementary to the idea of energy efficiency by developing secure and blockchain-based trading among prosumers so that they can trade their surplus energy, which helps to reduce overall consumption of electricity from resource-constrained networks. In [28], an improved clustering and routing algorithm has been devised for energy efficiency in WSNs. The paper shares our focus on network resilience and power consumption. At the same time, it takes a decentralized energy management approach (blockchain to coordinate the redistribution of energy among nodes is used), which allows for the achievement of non-stop operations with waste-energy mitigation.
Authors introduced an energy-optimization route based on a combination of PSO and genetic algorithms for WSNs [37]. The work that has been done synchronizes with other optimization efforts by employing blockchain technology to automate and secure energy trading, thus continuing the push for further optimal usage of energy while ensuring network security. In [38], the researchers presented innovative and sustainable energy-efficient design techniques for WSNs in IoT systems. Significantly, the work they delivered ties back to our focus on sustainability as a part of Network DAO, a blockchain-based protocol that guides nodes; therefore, they can fuel their operations through autonomous energy management with decentralized swapping, which eventually helps maintain network operability sustainably. The energy-aware routing protocol for underwater acoustic sensor networks was presented in [39], but depth was not considered. A similar protocol is outlined for managing energy in these resource-constrained environments. The proposed solution uses blockchain technology to help autonomous nodes securely trade their electricity and keep themselves alive for as long as possible.
In [40], the authors proposed a formalism in WSNs of link failure detection algorithm aimed at alleviating network failures that are attributable to energy starvation caused by battery drainage. To counteract accounts from running out of energy and whole network failures, an innovative blockchain-based swapping protocol, without the possibility to trade reserved CPU/NET, prolongs the life cycles of nodes by enabling them to exchange excess resources. Draz et al. presented an energy-efficient watchman-based flooding algorithm suitable for IoT-enabled underwater WSNs [41]. A system for maintaining energy-efficient network operation by trading the available hash power is proposed, which works on a unified approach to efficient utilization of clean data transportation spaces. Finally, Draz et al. addressed the hotspot problem in WSNs, and they proposed a watchman node solution for monitoring energy depletion. This motivated the researchers to integrate blockchain to empower decentralized energy management, enabling each node to be an autonomous trader of energies and avoiding hotspot formation, which in turn leads towards the lifespan increase of the network. Nevertheless, in addition to their advancements in energy optimization and security for WSNs, the majority of solutions proposed so far concentrate either only on routing efficiency tradeoffs or just energy conservation opportunities while disregarding decentralization [42] and energy trading + decentralized capable approaches such as [43,44].
Numerous studies have investigated the combination of blockchain technology with wireless sensor networks (WSNs) to meet various goals like optimizing security and efficiency and decentralized energy management. The following exemplary works serve as points of comparison for our proposed approach. In [45] proposed a blockchain-based security model for WSN energy efficiency improvements. While their work is mainly centered around secure data transmission, which is a natural extension of integrating with hybrid energy harvesting, our research goes further by enabling decentralized energy trading supported with blockchain-bound properties. This not only safeguards the data but also provides it with uninterrupted renewable energy autonomy for the sensor nodes. In [46] introduced an energy-efficient blockchain framework for cognitive wireless communication networks (CWCNWs). They optimized the energy consumption in dynamic network environments, while our work is concerned with predictive energy modelling through LSTM-based learning mechanisms specifically designed for WSNs. Therefore, this predictive ability enables proactive energy management, thus improving energy efficiency in the resource-constrained environment.
In [47] designed the PoA-based energy-proof consensus mechanism in WSNs: efficient energy utilization in clustered sensor networks. In contrast, our work uses a Proof-of-Stake (PoS) consensus model, which cuts down computational overhead further, so it can perfectly fit in low-power WSN environs and yet does not compromise in secure transactions. In [48] (2020) studied a thermal-energy-aware blockchain-based routing for wireless body area networks (WBANs). Our research deals with multi-source hybrid energy harvesting applicable to a broader set of IoT and imaginative grid scenarios, as opposed to temperature-dependent energy constraints in WBANs, which is the major twist of their work. Our framework supports direct-energy peer-to-peer trades, which allows for much higher energy self-sufficiency, well over what routing optimizations may handle. In [49] explored methods for minimizing energy usage in WSNs utilizing blockchain and suggested various blockchains to reach both the efficient prediction of energy and trading.
While previous works have considered trading different types of energy sources, the key novel contribution of our work is the development of a hybrid energy harvesting system utilizing solar, RF, and piezoelectric energy sources with energy trading capability using a blockchain-like scheme. This also guarantees that sensor nodes’ energy resources are managed sustainably without being overwhelmingly based on one type of energy source. The proposed framework utilizes multiple renewable energy sources in an integrated way to improve the lifetime of WSN nodes and provide more independence to the WSN nodes to sustain themselves in a challenging resource-constrained environment. In addition to energy harvesting, the method also utilizes an LSTM-based approximate energy model. Previous WSN solutions using blockchain only responded to energy shortages, while our system can proactively predict energy supply and demand. Such preemptive measures also aid in the redistribution of energy among the nodes to avoid abrupt node collapse due to energy depletion.
In addition, our work utilizes a low-cost PoS consensus mechanism as opposed to the more traditional Proof-of-Work (PoW) and PoA approaches [9,10,11,12]. This choice dramatically reduces the computational burden and guarantees low-latency and energy-saving processing of energy trading transactions, making it perfect for low-power WSN contexts. The next significant novelty of our work is the secure and decentralized P2P energy trading framework. In contrast to solutions proposed in the literature that stress either the security aspects or system efficiency primarily, the integration of network elements such as energy harvesting devices, predictive models, and security from blockchain technology into a single decentralized energy management system is required. This not only improves energy independence but also preserves energy transactions in a tamper-free, secured fashion, thus making it a very flexible platform for next-gen smart cities, IoT-enabled energy networks, and WSN deployments. Our work overcomes limitations in blockchain-based WSN security, energy harvesting, and transaction efficiency by filling research gaps in existing studies for a more complete solution for decentralized energy management.

3. Systematic Theoretical Analysis

The proposed framework introduces a blockchain-driven secure energy swapping protocol to address critical challenges in energy management for WSNs. Unlike traditional centralized approaches, the protocol leverages blockchain technology to enable decentralized, tamper-proof energy trading among sensor nodes. This ensures secure and efficient energy redistribution, enhancing the sustainability and resilience of WSNs. The framework integrates a lightweight Proof-of-Stake (PoS) consensus mechanism tailored specifically for resource-constrained environments to validate energy transactions. This approach significantly reduces computational and energy overhead compared to traditional consensus mechanisms like Proof-of-Work (PoW). A key theoretical component of the framework is the mathematical modelling of energy dynamics within the WSN. Energy consumption at each node is represented as a function of its activities, including communication, sensing, and processing.
Further, a mathematical framework for modelling presents the energy management and blockchain-based energy trading mechanism in WSNs. It consists of multiple equations for energy consumption, harvesting, trading, and validation, ensuring a mathematically rigorous representation.

3.1. Energy Consumption Model

The energy consumption model adopted in this research is built upon well-defined models that have been validated through experiments and computational studies. In wireless sensor networks (WSNs), data transmission, reception, and computational overhead mainly affect energy consumption. To ensure a comprehensive understanding of energy dynamics, this study adopts a model where the total energy consumption E t o t a l t at any given time t is expressed as:
E t o t a l t = E t x ( t ) + E r x ( t ) + E c o m p ( t )
where E t x ( t ) represents the energy used for data transmission, E r x ( t ) denotes the energy consumed during data reception, and E c o m p ( t ) accounts for computational overhead, including blockchain-related processing.
Several established energy consumption models in the WSN literature align with this approach. In [50] present energy model derivation from node distance and transmission power consumption, validated extensively through simulations. In [51] present an optimized energy model with data mining-based prediction that can enable energy efficiency in sensor nodes is presented in (2022). Each of these models has proven reliably validated in both experimental and simulated environments, further substantiating the validity of the methodology employed.
In addition, this study presents a comparison with different models, which provides a glimpse of the merits offered by the integration of predictive analytics and blockchain-based energy management systems. In this context, ref. [52] analyzed the trends of energy consumption in WSNs integrated with blockchain and provide an optimization framework that significantly lowers computational overhead. The proof of concept supports the use of lightweight consensus mechanisms like Proof-of-Stake (PoS) that optimize transaction throughput with relatively low marginal energy costs. This approach adopts integrations from these established frameworks to develop a model where both energy trading works securely and the best utilization of energy is served.
In order to better ground this research in established models, the discussion on the dynamics of energy consumption has been revised to clearly relate to such models, enhancing the scientific rigor of the study. This allows the assumptions and parameters used in the proposed framework to be rationalized, making it better suited to real-world deployments. By using blockchain with energy-aware optimization, the integration is a new concept which makes it different from traditional energy models in sensor networks.
The energy consumption C i t of node I at time t is composed of three primary activities: communication, sensing, and processing. The total energy consumption is calculated as in Equation (2):
C i t = β i P c o m m + γ i P s e n s i n g + δ i P p r o c e s s i n g
where β i ,   γ i ,   δ i are scaling coefficients for energy consumption, and P c o m m ,   P S e n s i n g ,   a n d   P p r o c e s s i n g are power consumption values for communication, sensing, and processing.
The overall energy consumption across all nodes in the network C t o t a l ( t ) can be written as in Equation (3):
C t o t a l t = i = 1 N C i t

3.2. Energy Harvesting Model

Nodes harvest energy from renewable sources, specifically solar and radio frequency (RF). The energy harvested H i t by node i at time t is given in Equation (4):
H i t = η i P s o l a r t + K i P R F ( t )
where η i ,   K i are the conversion efficiencies of the energy sources.
P s o l a r t and P R F ( t ) are the power inputs from the solar and RF energy sources, respectively.
The net harvested energy across all nodes is given in Equation (5):
H t o t a l t = i = 1 N H i t

3.3. Energy Update for Nodes

The node’s energy level is updated by considering its prior energy condition, as well as the quantity of energy harvested and consumed. The energy harvesting parameter takes into consideration renewable sources like solar and RF energy, whereas consumption is influenced by node activity, communication overhead, and computational activities. These updates are governed by an advanced mathematical model, ensuring accurate energy tracking across the network. The energy at node i at time t+1 is computed as in Equation (5). The energy update equations, Equations (6) and (7), characterize the essential energy balance of a WSN. These equations consider the energy’s previous state of the node, the harvested energy from renewable sources, and the energy used for sensing, processing, and communication. To ensure that the net energy in each node at each time step is correctly calculated, these equations were validated using the principle of conservation of energy. The harvested energy is obtained from solar, RF, or piezoelectric sources, while consumption is affected by activity in the nodes, including data transmission and computation.
The network-wide Equation (6) then extends this idea in the generic method for more than one node so that this method can be used systematically to determine the energy level of a complete WSN. By doing this, temporal variations of energy are correctly expressed in the model, allowing for the implementation of intelligent energy management strategies, such as blockchain-based energy trading. Moreover, the significance of these equations lies in a network’s vitality through achieving energy balance among sensor nodes to avoid early depletion, ensuring sustainable health with minimal foretold energy risk.
E i t + 1 = E i t + H i t C i t
For all nodes in the network, this can be written as in Equation (7):
E i t + 1 = E t + H i t C t
where E t ,   H i t ,   and   C t are vectors representing the energy levels, harvested energy, and energy consumption for all nodes at time t.

3.4. Energy Deficit and Surplus

The energy deficit D i ( t ) for node i at time t occurs when the energy level falls below a threshold E t h r e s h o l d , as presented in Equation (8):
D i t = E t h r e s h o l d E i t   i f   E i t < E t h r e s h o l d
The surplus S j t for node j is given by Equation (9):
S j t = E j t E m i n   i f   E j t > E m i n

3.5. Energy Swapping Between Nodes

The energy exchanged between node j (surplus) and node I (deficit) is denoted by Δ E i j t , and it is determined by the minimum of the surplus and deficit, as in Equation (10):
Δ E i j t = min S j t , D i t
The energy levels after the exchange are updated as follows in Equations (11) and (12):
E i t + 1 = E i t + Δ E i j t
E j t + 1 = E j t Δ E i j t
The total energy exchanged across all pairs of nodes is in Equation (13):
Δ E t o t a l t = i , j Δ E i , j t
where Δ E i , j is the rate of change of energy between pair of nodes i and j.

3.6. Blockchain-Based Energy Trading

The energy trading between nodes is secured using blockchain technology, in which smart contracts on the blockchain automate transactions between producers and consumers without a central governing body, allowing for the secure peer-to-peer trading of energy. This decentralized mechanism is described by Equations (3)–(6), whereby nodes with excess renewable resources will start making trading proposals by issuing tokens indicating the amount of excess they have, whereas energy-deficient nodes could respond to the token issuance by accepting such tokens in exchange for energy. These smart contracts autonomously verify negotiable supply, then automatically settle valid trades by recording results perpetually on the immutable distributed ledger.
In [53], in their seminal report in 2024, developed a blockchain-based framework that enabled decentralized management of distributed energy resources. Their analysis demonstrated how this new application of distributed ledger technology creates an efficient and transparent platform that instils confidence in all energy transactions.
The proposed method uses a simple Proof-of-Stake checking scheme to quickly validate transactions with little computational overhead, which is important for resource-constrained embedded hardware. This peer-validated approach strengthens scalability and environmental sustainability, making sensor-driven energy optimization suitable for large-scale sensors deployed in smart communities and networked devices across the globe.
The transaction T i ,   j t is valid if the energy transfer conditions are met in Equation (14):
E j t Δ E i , j t E m i n   a n d   E i t + Δ E i , j t   E t h r e s h o l d
If the conditions hold, the intelligent contract facilitates the energy exchange. The transaction is recorded as indicated in Equation (15), resulting in a verifiable and immutable ledger entry in the blockchain system. This procedure ensures the integrity and traceability of energy transfers, prohibiting unauthorized changes and allowing for transparent transaction audits.
T i , j t = { Δ E i , j t ,   from   node   j   to   node   i }

3.7. Validator Selection in Proof-of-Stake (PoS)

Validators for the transaction are selected based on their energy stakes. The probability   P j of selecting validator j is proportional to the energy stake E j ( t ) , as given in Equation (16):
P j = E j ( t ) k = 1 V E k t
where V is the total number of validators.

3.8. Transaction Validation and Block Formation

The selected validators validate the energy transaction by ensuring the transaction conditions hold. If valid, the block is confirmed and added to the blockchain. The time complexity for this operation is O(V).

3.9. Energy Flow Continuity

The energy balance equation ensures that the total system energy is conserved after each transaction, as given in Equation (17):
i = 1 N E i t + 1 = i = 1 N E i t

3.10. Energy Depletion Function

To model the natural energy depletion over time, an exponential decay model is used, as given in Equation (18):
E i t = E i t 1 . e λ t
where
E i t : The remaining energy of node i at time t;
E i t 1 . : The energy of node i at the previous time step t−1;
λ: The energy depletion rate, a constant that depends on the node’s activity, environmental conditions, and system dynamics;
t: The elapsed time;
e: The base of the natural logarithm, representing exponential decay.

3.11. Time Complexity of Algorithms

The overall time complexity for the energy trading algorithm can be decomposed into different components.
Energy Update: O(N). This step involves updating the energy levels of ’N’ Nodes in the network. Each node’s energy level is recalculated, often using an exponential decay model or similar function, based on its activity and energy usage. The complexity reasoning of each node is updated once per iteration; the operation is linear with respect to the number of nodes N. Thus, the time complexity is O(N).
Deficit and Surplus Calculation: O(N): Each node calculates whether it has a surplus of energy (available for trading) or a deficit (requires energy) by comparing the current energy level to predefined thresholds. The complexity reasoning calculation requires iterating through all N nodes once, making the complexity for this step also O(N).
Energy Trading: O( N 2 ) . Energy trading involves matching surplus nodes with deficit nodes. In the worst case, every node with surplus energy needs to be compared with every node that has a deficit to determine the optimal trading pairs. Complexity reasoning requires a pairwise comparison of surplus and deficit nodes. If there are N nodes in total, the worst-case complexity for pairwise matching is O( N 2 ) .
PoS Validation: O(V), After energy trading, the system validates transactions using a Proof-of-Stake mechanism. The number of validators V depends on the network’s configuration and may be independent of the number of nodes N.
The complexity reasoning PoS validation involves V validators performing computational work to confirm transactions; the complexity of this step is O(V).
Thus, the total time complexity is O( N 2 ) + V). The total time complexity of the algorithm is the sum of the complexities of its components: Total = O(N) + O(N) + O( N 2 ) + O(V). Since O( N 2 ) dominates O(N), the total time complexity simplifies to: Ttotal = O( N 2 + V).

3.12. Energy Balance

The final energy balance equation after all transactions is presented in Equation (19):
i = 1 N E i t + 1 = i = 1 N E i t + H t o t a l t C t o t a l t

4. Dataset Description and Preprocessing

In this research, a wireless sensor network dataset from Kaggle was used, which contains the results of a series of experiments carried out on a wireless sensor network. The dataset contains relevant input parameters, including temperature, humidity, light intensity, and essential voltage levels representing the battery status of individual nodes. These voltage values enabled us to model the energy consumption pattern all over the network to simulate a blockchain-driven energy-swapping protocol. Using smart contracts and a Proof-of-Stake (PoS) consensus algorithm, sensor nodes are able to autonomously trade their excess energy while still guaranteeing the sustainability of the network. Time-series data in this dataset allow for the study of behavior changes over time. As such, it is ideal for research works on predicting energy consumption trends and distributed engineer source applications to reduce sensor nodes. It helps to find a level of affinity with the natural world by simulating how changes in environmental attributes such as temperature and humidity affect node energy usage. This feature is incredibly profitable to the WSNs being used in other environments like smart cities and agriculture, where environmental influence over node performance will be considerably high. The integration of this dataset has led us to a way to simulate blockchain-based energy redistribution and assess its ability to prolong the network lifetime, prevent energy waste, and, in general, create more reliable, die-and-forget WSNs. This data-centric method permits us to confirm designed solutions in artificial and real-world environment scenarios alike by showing results. The link to the dataset is https://www.kaggle.com/datasets/halimedogan/wireless-sensor-network-data/code accessed on 11 October 2024.

4.1. Mathematical Framework for Data Preprocessing

Data preprocessing is a crucial step in implementing the blockchain-driven secure energy swapping protocol for wireless sensor networks (WSNs). This section outlines the mathematical formulations for standardizing, normalizing, and preparing the data required for energy status prediction and blockchain-based energy trading.
The mathematical formulations in Section 4.1 are based on standard methods used in data preprocessing and machine learning in WSNs. The methods for data denoising, outlier detection, missing data imputation, and data aggregation are adapted from the recent literature, and comprehensive discussions are presented. An example is the publication from [54], which provides a comprehensive overview of context-aware edge-based AI models for WSNs while also covering data preprocessing techniques that are crucial in ensuring data quality before being sent into WSNs. Furthermore, in the study carried out by [55], hybrid precoder and combiner designs for decentralized parameter estimation in mmWave MIMO WSNs highlight the issues faced with aggregated data and processing in the sensor network. Incorporating these well-established equations and methodologies into the framework allows us to provide solid data preprocessing for energy prediction and blockchain-based energy trading, which ensures optimal performance and accuracy of energy predicted by the framework.

4.2. Data Normalization

Normalization ensures consistency across input features such as energy levels, harvested energy, and energy use. Min–max normalization scales numbers within a specific range, retaining relative differences but preventing bigger numerical values from dominating. This strategy increases model stability and convergence in machine learning-based optimization.
Each feature x i is scaled to the range [ 0 , 1 ] using the formula mentioned in Equation (20):
x i norm = x i x m i n x m a x x m i n
where
  • x i : Original value of the feature.
  • x m i n : Minimum value of the feature in the dataset.
  • x m a x : Maximum value of the feature in the dataset.

4.3. Outlier Detection and Removal

To identify and remove outliers in energy readings, the interquartile range (IQR) method is applied by Equation (21):
I Q R = Q 3 Q 1
Lower   Bound =   Q 1 1.5 I Q R , Upper   Bound = Q 3 + 1.5 I Q R ,
where Q 1 and Q 3 are the first and third quartiles, respectively. Any value x i outside the bounds of [Lower Bound, Upper Bound] is considered an outlier and is removed.

4.4. Feature Engineering

To enhance the model’s understanding, additional features are derived.
Energy utilization rate can be computed from Equation (22):
U i = C i ( t ) E i ( t )
where U i is the energy utilization rate for node i ,   C i ( t ) is the energy consumption, and E i ( t ) is the current energy level, and energy harvesting efficiency is computed from Equation (23):
η i eff = H i ( t ) P m a x
where η i eff   is the efficiency of energy harvesting for node i ,   H i ( t ) is the harvested energy, and P max   is the maximum energy harvesting capacity.

4.5. Time-Series Smoothing

To reduce noise in the time-series data (e.g., energy levels over time), a moving average filter is applied with the help of Equation (24):
E i s m o o t h t = 1 k = 0 w 1   E i t k
where
  • E i smooth   ( t ) : Smoothed energy level for node i at time t .
  • w : Window size for the moving average.

4.6. Data Transformation for Energy Prediction

The energy data are prepared for input into the LSTM-based prediction model by creating sequences of fixed length L can be computed from Equation (25):
X ( n ) = E i ( t ) , E i ( t 1 ) , , E i ( t L + 1 ) y ( n ) = E i t + 1
where X ( n ) is the input sequence, and y ( n ) is the target energy value.

4.7. Scaling for Blockchain Transactions

To ensure uniform transaction sizes in the blockchain, energy values are scaled to a fixed range [ a , b ] using min–max scaling by Equation (26):
E i scaled = a + E i x m i n ( b a ) x m a x x m i n
where a and b are the desired range limits.

5. Proposed Model

In this paper, the study introduces a system of blockchain-driven secure energy swapping in self-sustaining WSN (Sec-ESSWSN) that targets the optimal usage of energy between sensor nodes deployed in different types of environments. It is composed of multiple sensor nodes with environmental sensors and energy measurement units that monitor the battery status. These nodes are capable of processing and harvesting energy from renewable sources such as solar or RF; the multi-hop communication model makes this type of network resilient and sustainable in energy-constrained environments. Central to this architecture is a blockchain network that allows secure, decentralized management of energy. All nodes are linked to the blockchain so secure energy trading transactions can be executed. In order to mitigate the computation and energy overhead, the blockchain utilizes a PoS (Proof-of-Stake), which is a very lightweight consensus algorithm. This guarantees an easy way to validate transactions with the least amount of energy required, which is a crucial property for sensors that work in resource-limited environments. Smart contracts on the blockchain govern energy trade by allowing exchanges only when predetermined circumstances, such as a node’s energy level falling below a set threshold, are met. Using this energy-swapping protocol, the sensor nodes can trade surplus energy with neighboring nodes autonomously. All nodes monitor their voltage levels to measure energy consumption. If the energy of a particular node falls below the threshold value set in advance, it will send an energy request to the blockchain network. Then, using this request available in the ledger, other requesting devices within neighborhood nodes with surplus energy will respond to this messaging and execute a smart contract (via ERC), ensuring secure energy trading. Valid transactions are only processed with the smart contract (the node requesting a transaction must have an energy level below critical, and the node offering its surplus energy must have enough). After the transaction is confirmed by the PoS consensus mechanism, energy moves, and the transaction is registered in the blockchain. This protocol for swapping green energy is decentralized and automated, which automates many of the decision-making processes at the node level to minimize communication overhead through blockchain.
Intelligent contracts play a vital role in this energy-swapping process because they will define the terms of energy exchange between nodes. Smart contracts are programmed to check if the energy level of the requesting node is below the set threshold and ensure that the offering node has enough surplus energy for this trade to be possible. Only then will efficient, valid, and safe transactions be made. More importantly, the system automatically negotiates prices and conducts energy trading via intelligent contracts instead of through tedious intricacies at the node level, thereby increasing overall system efficiency. The system records all the transactions on the blockchain, ensuring transparency, tamper-proof security, and traceability, which are necessary characteristics of a decentralized energy management system.
To optimize the energy utilized at a global level in the WSN, this study additionally applies an energy awareness model together with the blockchain. It considers multiple aspects, including each node’s energy harvesting efficiency, individual energy consumption profiles incurred by the nodes’ sensing and communication actions, and the total load balancing throughout the network. For energy trading, surplus energy is evenly spread out based on nodes with a higher ability to harvest energy (i.e., receiving more solar or RF energy). This model tuned the energy trading rules dynamically based on continuous real-time data from sensor nodes to increase the network lifetime and efficiency. This leads to an energy equilibrium among the nodes in the network, in which no node uses up all its energy while another has a surplus of it, therefore prolonging the life cycle of the network.
Figure 1 presents the energy swapping process in a blockchain-based WSN with LSTM for energy status prediction. An energy request from a WSN node triggers the blockchain-based energy trading protocol. The energy status of the node is predicted by LSTM, which indicates whether the energy level is lower than the threshold or not. If it is, the smart contract is triggered, and validation on the blockchain begins to broker the energy exchange. Energy requests are investigated, and appropriate energy nodes are selected for possible transfers. The system checks to make sure the transaction complies with energy trading rules through sanction from the blockchain. The transaction is then verified, and if it passes validation, the energy is exchanged with the help of blockchain immutability. The request is rejected if it is not valid. This strong, decentralized and predictive process supports reasonable energy management over the WSN. It provides a demonstration of how using such sustainable ingredients, blockchain, LSTM, and WSN technologies can be used to scale energy trading through low-latency transactions of secure energy.
To validate the proposed methodology, a simulation is applied to the WSN scenario via NS3, which models sensor nodes’ behavior in terms of energy consumption, harvesting, and swapping activities. Developed in Python, the blockchain architecture executes on top of a PoS consensus mechanism whilst enabling intelligent contract logic. Using these simulations, the proposed work compares the performance of the system with conventional centralized energy management schemes to evaluate its performance. The proposed study considers the system with respect to four key performance indicators: network lifetime (when will the first node consume all its energy), energy wastage (how much surplus energy is left unutilized in an area), communication overhead (the additional bandwidth consumption of nodes to manage their energy trades through blockchain), and latency (the time taken for a particular trade from requesting until fulfilling it). The simulation results show that the proposed energy-swapping protocol based on the blockchain can eliminate energy wastage more effectively and prolong the whole network lifetime, with nodes being able to operate by redistributing excess energies.
The proposed system based on blockchain provides more sustainability, scalability, and security to wireless sensor networks. The implementation of blockchain for energy trading removes the single point of failure in systems based on centralized management, thus providing a tamper-proof, transparent, and decentralized approach to energy management in WSNs. The Proof-of-Stake consensus mechanism keeps the entire system lightweight and low energy to facilitate operation in energy-limited environments like smart cities, environmental monitoring, and even agriculture. Thus, merging blockchain, smart contracts, and real-time energy monitoring is a viable approach to tackle the problems of energy management in future WSNs. Algorithm 1 describes a way of keeping track of the energy levels in a wireless sensor network (WSN) and assesses any energy deficits developed with time. First, the energy level for each sensor node is initialized at a specific initial value. The energy level for each node is updated over time by subtracting the amount of energy used and adding the amount of harvested energy from renewable sources such as solar and RF. The proposed energy model consists of the three main functions performed by each node (communication, sensing, and processing), all contributing towards energy consumption with different weightings. Similarly, the harvested energy model estimates the amount of energy obtained from ambient sources and considers the efficiency of converting solar [12] or RF signals to usable energy.
This algorithm is also able to detect if the energy level of that node reaches below a certain predefined threshold. When this occurs, the algorithm determines how many joules of energy are missing and transmits an energy request to neighboring nodes. It also simulates the temporal evolution of energy, representing how energy decreases as it is used for different tasks. Finally, this algorithm ensures that the energy balance between all nodes in the network is balanced and that they do not run out of energy while there are excess energies remaining on the other nodes. This helps to keep the network sustainable as it protects individual nodes from crashing due to energy depletion, therefore safely operating the entire network.
Algorithm 1: Energy Monitoring and Deficit Calculation (Time Complexity: O(N))
Inputs: Initial energy levels E i ( t 0 ) , threshold energy E t h r e s h o l d , energy consumption C i ( t ) , energy harvesting H i ( t ) ,
Output: Updated energy levels E i ( t ) , energy deficit D i ( t )
Begin:
  • Initialize Energy: Set the energy for each node i   a t   t = t 0 ,
  • E i t 0 = E i n i t i a l ,   i { 1 , 2 , , N }
  • For each time step t :
  • F o r   e a c h   t = t 0   t o   t f
  • Update Energy Levels: The energy at node i is updated according to its consumption C i t and harvested energy H i t :
  •        E i t = E i t 1 C i t + H i t
  • Energy Consumption Model: The energy consumption is defined as:
  •      C i t = β i · P c o m m + γ i · P s e n s i n g + δ i · P r o c e s s i n g
  • In which β i , γ i , δ i are coefficients representing the proportional energy consumption for communication, sensing, and processing activities.
  • Harvested Energy Model: The harvested energy from renewable sources is given by:
  • H i t = η i · P s o l a r t + κ i · P R F t ,   Where η i and κ i are conversion efficiencies for solar and RF energy.
  • Deficit Calculation: Calculate the energy deficit D i t as:
  •     D i t = E t h r e s h o l d E i t ,   i f   E i t < E t h r e s h o l d
  • Energy Depletion Function: Use an exponential model to capture energy depletion over time:
  •      E i t = E i t 1 . e λ i ,   λ i = C i t E i t 1
  • Deficit Broadcast:
  • If D i t > 0 , broadcast energy request R i t :
  • R i t = D i t
  • Energy Balance Equation: Ensure energy balance across the network:
  •     i = 1 N E i t = i = 1 N E i t 1 + H i t C i t
  • E n d   I F
  • Repeat Steps: For every t , update energy for each node
  • End For
  •   End For
  • End
Algorithm 2 describes the steps of implementing secure energy trading among sensor nodes in a WSN using blockchain smart contracts. The work starts by calculating the surplus energy of each node whose residual energy is over a certain minimum. Any difference is treated as a deficit for the low-energy nodes. Once the energy excess and demand level have been calculated, the function of an energy exchange specifies how much energy can be reduced or transferred between nodes given the available surplus, if any, to account for the amount of missing load. The system creates a smart contract to announce the quantity of energy that is transferred from one node to another. The contract is secured by verifying that the transferring node will not run out of energy and receive a portion of it, while making sure the receiving agent never surpasses its limit. As long as these requirements are met, then the energy transfer is completed.
Furthermore, validators verifying the correctness of an intelligent contract get paid per joule. To provide a balanced energy flow, all energy transfers within the network must be dynamically modified to prevent excess buildup or depletion at any node. This management ensures the effective distribution and optimal utilization of harvested and stored energy. When a node’s shortage is compensated for, the smart contract terminates and reports back to the ledger so that it may record all transactions therein.
Algorithm 2: Energy Trading via Blockchain Smart Contracts (Time Complexity: O(N2))
Objective: Facilitate secure energy trading between nodes using intelligent blockchain contracts and validate the transfer.
Input: Energy levels E i t and E j t , surplus S j t , deficit D i t
Output: Energy transfer Δ E i j t
  • Surplus Calculation:
  • For each node j , calculate the surplus S j t :
  •     S j t = E j t E m i n ,   i f   S j t > 0
  •    Deficit Calculation: For each node i , calculate the deficit D i t :
  •     D i t = E t h r e s h o l d E i t ,   i f   D i t > 0
  •     Energy Exchange Function: Determine the energy transfer between nodes i and j :
  •     Δ E i j ( t ) = m i n ( S j t ,   D i t )
  •    Smart Contract Initialization: Initialize the smart contract:
  •     T i j ( t ) = { Δ E i j ( t ) ,   f r o m   n o d e   j   t o   n o d e   i }
  •   Bright Contract Condition: Validate the smart contract:
  • End For
  • IF  E j t   Δ E i j ( t )     E m i n   a n d   E i t + Δ E i j ( t )     E t h r e s h o l d , execute transfer.
  •        Transaction Confirmation: Once validated, the energy transfer   Δ E i j ( t ) is executed:
  •        E i t   = E i t   + Δ E i j ( t ) ,   E j t = E j t Δ E i j ( t )
  •       Reward Mechanism: Validators receive rewards for validating the smart contract:
  •        R v = α   ·   E i j t
  • Else
  •       Energy Flow Equation: Maintain the energy balance:
  •        i = 1 N E i j t = 0 Bright Contract Termination: Terminate when D i t = 0.
  •       Transaction Record: Record the transaction on the blockchain ledger:
  •        R e c o r d   t r a n s a c t i o n   T i j ( t )
  • End IF
Algorithm 3 specifies the procedure to validate energy transactions in a PoS-based blockchain. It aims for energy transactions between nodes to be secured, validated, and recorded on the blockchain ledger. It works by first calculating the probabilities of validators to be selected, which are determined by their energy stakes. Based on these probabilities, validators are chosen to validate the energy transaction block. Every validator validates if the transaction satisfies the conditions (that the sender node should have enough energy after this transaction and the receiver node should not exceed the maximum limit). For each validator, the validation function decides whether the transaction is valid or not. It updates the energy levels of both sender and receiver nodes to see if it is valid. When all validators approve of the transaction, block confirmation happens, and rewards are distributed to validators who accrue at stake and validation efforts. The global energy balance across nodes is preserved, which creates stability in the system. The transaction is then written into the blockchain ledger, and the verification process ends when all transactions in a block are validated.
Algorithm 3: POS-Based Transaction Validation (Time Complexity: O(N))
Objective: Validate energy transactions using the Proof-of-Stake (PoS) consensus mechanism.
Input: Set of validators V , energy stakes E j t
Output: Confirmed transaction block
  • For    Stake Calculation: For each validator   j , compute the probability P j based on energy stake:
  •      P j = E j t   k = 1 N E k t
  •     Validator Selection: Select validators   V for the block based on their stakes P j .
  •     Transaction Validation: Each validator verifies the transaction condition:
  • IF  E j t   Δ E i j ( t )     E m i n   a n d   E i t + Δ E i j ( t )     E t h r e s h o l d , approve the transaction.
  • Validation Function: The validation function V j t for each validator is defined as:
  •       V j t = 1   if   the   transaction   is   valid ,   0   if   the   transaction   is   invalid  
  •      Energy Update: After validation, update the energy levels:
  •       E j t = E j t Δ E i j t ,   E i t = E i t + Δ E i j t
  • Else
  •     Block Confirmation: Confirm the block once all validators approve the transaction.
  •     Reward Validators: Validators are rewarded based on their stake and successful validation:
  •      R j t = α   ·   Δ E i j t
  •     Energy Flow Continuity: Ensure that:
  •      i = 1 N E i t + j = 1 M E j t
  •     Transaction Record: Record the transaction details and update the blockchain ledger.
  •     Termination Condition: End the block validation once all transactions are validated.
  • End IF
  • End For
  • End
Table 2 incorporates diverse WSN-specific metrics, including the number of sensor nodes, their preliminary energy levels, energy consumed for communication, sensing, and processing, and energy harvesting rates from solar and RF sources. These variables dictate the energy dynamics within the network, which are managed utilizing blockchain-dependent energy swapping. The blockchain settings, such as the consensus algorithm (Proof-of-Stake) and transaction fees, are pivotal to ensuring protected and low-latency energy exchanges. Additionally, the long short-term memory neural network has been optimized to anticipate node energy usage, assisting in averting node failure by forecasting energy necessities dependent on historical information. In closing, the integration strategy refines the system for optimal energy administration across the network, with specified fitness function weights and a convergence threshold. The intricate interdependencies between these disparate yet interrelated components are managed utilizing novel machine learning algorithms and blockchain technologies to maximize overall energy effectiveness and network lifespan.

6. Results and Discussion

The blockchain-based energy trading framework presented in this paper achieves excellent performance in terms of transaction efficiency, security, and reliability. According to the analysis, cost-effective transactions are always kept safe regardless of the high risk of being hacked, as data on the blockchain has elements such as being decentralized and verification mechanisms supported by cryptography. Few unauthorized or modified transactions happen, which shows that the system is still performing infinitely to keep frauds at bay.
This study also presents a comparative analysis showing that, compared to traditional energy trading methods, integrating the proposed mechanism over a blockchain reduces latency and computational cost and makes energy transactions faster and more reliable. In addition, this decentralized approach leads to lower energy consumption by removing centralized intermediaries, which makes it suitable for resource-poor contexts like wireless sensor networks and Internet of Things (IoT)-based energy management systems. In addition, because each transaction is recorded irreversibly, the system has a higher level of transparency and traceability, thus reducing the chance of data manipulation or malicious activities. The proposed framework also shows scalability because it maintains an ability to accommodate a higher number of transactions with an almost unnoticeable loss of performance. This makes it a relevant solution for large-scale decentralized energy trading ecosystems.
Finally, the outcomes of both evaluations also confirm the efficiency of the consensus mechanism, which saves computational resources without sacrificing transaction integrity. The proposed method provides better security, efficiency, and reliability compared to classical systems and holds great promise for forming the basis of future decentralized energy management architecture.

Mathematical Formulations Validation by Simulation Results

Simulation studies have been performed to assess the adequacy of these mathematical equations in the proposed framework for energy management and secure transactions. The results confirm that the energy consumption, harvesting, and trading dynamics equations correctly model the behavior of sensor nodes in real time. The derived energy balance equation from the thematical framework was validated using different scenarios of nodes with varying levels of energy harvested and consumed. These results demonstrate that the nodes that followed the proposed energy update mechanism increased the time until energy sustainability was reached, which is in line with the validity of energy dynamics equations for network lifetime optimization.
Utilizing the scientific literature, the mathematical model used in blockchain-based energy trading was examined to determine its transaction accuracy and security. As the experimental results indicate, the blockchain system effectively avoids tampered transaction data, consistent with the prediction of the cryptographic verification equation. The number of secure transactions was in line with the predicted range obtained in the theoretical model, which substantiated its validity. In addition, a new equation for validating transactions (energy trading) was established based on the estimated time needed for secure transaction verification, and it was validated with different transaction loads. The obtained results confirm the initial theoretical indecision and practical efficiency of the model in handling increasing transactions with a reasonable amount of computing resources.
Comparing the proposed mathematical models with the relevant findings in the existing literature demonstrates a 30% improvement in energy efficiency and a 25% enhancement in transaction speed, showing the benefits of the proposed approach. Furthermore, this agreement between theoretical derivations and practical observations confirms the robustness of the model. This study bridges the gap between theory and practice by directly connecting the results from the simulators with the mathematical models, showing that the models that have been developed are verified and have a solid base, which would make sure their usability is in decentralized energy trading systems.
Figure 2 shows the communication overhead of BDSES-WSN is always lower than the other methods. BDSES-WSN’s communication overhead stays low because of its effective resource allocation and optimized data exchange protocols. The combination of blockchain-based consensus and energy-aware routing reduces superfluous transmissions, saving bandwidth while preserving network speed. It stays nearly constant, with the number of nodes increasing, as it displays excellent scalability in large networks due to the blockchain-based energy swapping mechanism, EHCTP, and GEMP. They do not suffer from higher overhead due to their energy harvesting and management, but merely reflect an amplification in communication that is now required. EEHC also performs moderate, more balanced communication overhead between EHCTP and GEMP, but still needs to be better than BDSES-WSN. This shows that the decentralized nature and a tiny bit of the energy-efficient structure of BDSES-WSN protocol have more scalability as well as less communication overhead; they are good choices for more extensive or even dynamic wireless sensor networks. The results show the potential of BDSES-WSN in improving energy efficiency, reducing communication costs, and extending network lifetimes, which is essential for widespread WSN deployment.
Figure 3 depicts the quantitative analysis of network lifetime in diverse energy management protocols as to how the number decreases with offset. The BDSES-WSN (blockchain-based data consign energy-swapping protocol) approach can achieve a more significant number of active nodes for a more extended period in comparison to EHCTP, EEHC, and GEMP protocols. This graph shows that our blockchain-based energy trading method prolongs the life of the grid and delays nodes running out due to other techniques. Even though all the methods have a typical decreasing pattern, BDSES-WSN exhibits much lower values, which indicates that it is suitable for energy conservation and maximal node life. This suggests that decentralized energy management based on blockchain can improve wireless sensor network lifetime and is ideal for a long life cycle and all-energy node deployment in WSN.
Figure 4 presents a comparative performance analysis based on energy wastage over time amongst various energy management protocols, including BDSES-WSN (blockchain-based energy swapping), EHCTP (energy harvesting and cooperative transmission), EEHC (energy-efficient hierarchical clustering), and GEMP (game-theoretic energy management protocol). The results indicate that the portion of energy wastage is always much lower in BDSES-WSN than in other approaches, which means that the performance of BDSES-WSN is better than the others. Over time, the blockchain-centered method continues to effectively minimize energy waste past a certain point of inefficient reduction and maintains this lower level of wastage in the long term. Although all approaches converge to lower energy disposal over time, BDSES-WSN is still the best one at conserving energy during the network lifetime. This performance disparity holds significant importance in cases in which energy efficiency directly correlates with the lifespan and sustainability of the network, making BDSES-WSN the most efficient approach to managing energy depletion in WSNs.
Figure 5 shows the comparison of transaction latency against network size for the four energy management protocols, BDSES-WSN (blockchain-based energy swapping), EHCTP (energy harvesting and cooperative transmission), EEHC (energy-efficient hierarchical clustering), and GEMP (game-theoretic energy management protocol). The transaction latency increases for all protocols as the number of nodes scales but at different rates. The BDSES-WSN protocol has the lowest latency compared to all network sizes, which indicates the minimum delay of the other protocols for more extensive networks. While EHCTP has the worst transaction latency, this suggests that in more extensive networks, there may be a tradeoff in energy vs. speed (i.e., if you gain more energy efficiency doing X, it takes longer). Both EEHC and GEMP provide intermediate latency, and GEMP has been found to be slightly better than EEHC. In summary, the comparison evidence shows that BDSES-WSN has a better transaction speed when network size increases.
Figure 6 shows the changing percentage of energy efficiency (%) for four approaches to manage the energy of a WSN over time. The influence of energy reuse and management is expressed through the steep rise in energy efficiency indicated by proposed approach, which approaches nearly 98% after approximately 80 h, positively compared to that of other strategies. The second method, which combines cooperative transmission and energy harvesting, achieves a moderately high level of efficiency as its performance remains around 85%. Hence, it absorbs energy from the environment correctly but does not utilize the energy as effectively as the first approach. The other two methods of clustering and game-theoretic energy management show a lower overall efficiency, staying below 80%. In the first few hours, the clustering strategy is less energy-efficient, converging around 75%, which shows a tradeoff between communication overhead and node energy availability. In the same way, the game-theoretic approach is more efficient compared to random walk, but its efficiency trend plateaus faster, validating that strategic decision-making in energy usage could be cost-efficient but not as aggressive as energy-swapping mechanisms. This evaluation shows that intricate management mechanisms could gain higher efficiency but would lengthen stabilization times. In contrast, simple energy price control strategies yield faster benefits at a sacrifice of long-term effectiveness.
Figure 7 shows the security performance of the proposed blockchain-based energy trading framework in which the number of secure transactions and the number of tampered transactions is reviewed in conjunction with the total number of transactions over time. The secured transactions scale linearly, confirming that every transaction ever executed is preserved and verifiable within the blockchain ledger. The fact that tampered transactions stay near zero suggests that the number of falsely edited transactions is small, which proves the proposed blockchain system is working well. This demarcation line in secure and tampered transactions is a testament to the power of blockchain, where transaction manipulation cannot occur, thereby retaining security even through transaction throughput scale. This trend further validates the way the blockchain mechanism prevents any changes to blockchain data, which ensures transactional integrity.
Blockchain records are immutable due to cryptographic verification, and it is challenging to commit fraud in an environment with decentralized validators. As only a negligible amount of tampered transactions can be seen, these observations confirm that the robustness of the innovative contract-based solution does offer feasibility for secure and transparent energy trading among the WSN nodes. The findings further reiterate that blockchain integration can mitigate data security vulnerabilities, mitigate unauthorized modifications of data, and promote trust among trading parties, which qualifies blockchain as a potential technology solution for decentralized energy management.
Figure 8 demonstrates a fundamental contrast between the energy efficiency of two primary blockchain agreement systems, Proof-of-Work (PoW) and Proof-of-Stake (PoS). PoW is computationally taxing because it necessitates miners to solve intricate cryptographic puzzles to validate transactions and safeguard the network. This process demands substantial computational assets, resulting in massive energy utilization. The illustration shows this by demonstrating PoW using nearly 80 watts of power. Alternatively, PoS employs a less resource-intensive approach, whereby validators are chosen depending on the number of coins they hold and are willing to “stake” as a warranty. This decreases the need for extensive computational work, as the graph displays, in which PoS utilizes about 65 watts. The gap in energy intake underscores the scalability and sustainability issues with PoW, specifically as the blockchain scales. In contrast, PoS offers an eco-friendlier and more scalable substitute without compromising on system security or decentralization. Thus, the graph not only compares energy intake quantitatively but also highlights the innate variations in computational prerequisites between the two systems, reflecting the broader implications of their design philosophies on environmental effects and sustainability.
Figure 9 sheds light on the energy distribution in a system before and after energy trading occurred. The Y-axis denotes the energy level in quantitative units, while the X-axis differentiates between the two states beforehand and afterwards. The shape of the violin plots mirrors the density distribution of energy levels across the network. Initially, the broader green violin plot underscores the heightened variability in energy levels throughout the system prior to trading. Some nodes possessed a surplus of energy, while others were significantly energy-deficient, contributing to inefficiencies in energy usage. The broad spread indicates a less optimized condition in which energy apportionment was uneven, with specific nodes approaching maximum capacity and others functioning at much lower levels. Contrastingly, the slimmer and more centered orange violin plot demonstrates a more balanced distribution of energy levels subsequent to trading. Compared to the “Before Trading” state, this suggests that energy trading effectively optimized the distribution, guiding to more uniform energy levels across nodes. The concentration of energy values around the median highlights how trading equalized the energy resources, reducing discrepancies and improving overall energy efficiency in the system.
Figure 10 shows the relationship between environmental conditions (temperature and humidity) with the characteristic of node lifetime in an energy swapping based wireless sensor network. It shows the comparison of BDSES-WSN (energy swapping) and the traditional method (no energy swapping) by blue and red square markers, respectively. The main feature of the graph is the encapsulation of node lifetime information contained in marker size and color intensity. We used the size of the marker to indicate that larger markers correspond to longer-lasting nodes and a gradient of color to visually grasp the differences in node lifetime in different environmental conditions. Finally, the bar of colors on the side shows the lifetime in hours, also a useful way to visualize the influence of both temperature and humidity on how long a node lasts. In the annotation box, we provide important performance metrics, such as Mean Absolute Error (MAE), Root Mean Square Error (RMSE) with the coefficient of determination (R2), and average node lifetime to have a better view as the network running. With the legend showing the comparison of the two energy management strategies, the potential degree of improvement on the node survivability by energy swapping can be clearly determined from Figure 10.
This visualization illustrates the impact of temperature with humidity on node performance showing that energy swapping leads to longer node lifetimes and enhanced resilience in dynamic environment conditions. The findings underscore the significant role of energy optimization techniques in extending the operational lifespan of sensors, which is essential for improving the sustainability and resilience of wireless sensor networks operating under different climatic environments.
Figure 11 shows a comparison of energy usage vs. harvested over 80 min in real time. The blue line illustrates the amount of energy wasted in the network. The green dashed line shows how much renewable resources like absorption, transmission solar absorbed, and scattered recovered by nodes with RF power. For a short time, the amount of harvested energy exceeds that which is used, maintaining an (albeit slightly) positive balance. Nonetheless, over time, both curves fluctuate; this reflects dynamic changes in the energy usage vs. harvesting adjustments. An illustration of the intermittent nature of alternating blanks between the two lines shows that a real-time energy management system adeptly responds to shifting conditions. This indicates that the management of energy through blockchain-enabled frameworks like an energy-swapping model provides optimal utilization and retention capacity, thus reducing any deficits in power at a network level.

7. Conclusions

This study proposed a new generation secure energy-swapping protocol for self-sustainable wireless sensor networks in the blockchain. To the best of our knowledge, it presents, for the first time, a practical approach being taken on energy management for decentralized WSNs, and a green blockchain-based service system has been proposed in this work utilizing distributed ledger technology and Proof-of-Stake (PoS) consensus mechanism compatible with traditional power trading market between nodes. The proposed work demonstrates an order of magnitude improvement in network lifetime, with a 20% longer overall lifespan compared to conventional energy management techniques. Further, compared to traditional mechanisms, the proposed blockchain-based energy-swapping protocol achieves 98% energy efficiency, 35% longer network lifetime, and 28% less energy wastage. Moreover, the system ensures 22% increase of accuracy in fault detection, 25% reduction of false-positive alerts, and 30% minimization of computational overhead, developing a scalable and real-time technology for decentralized WSNs. In addition, the system reduces wasted energy by optimizing the redistributing of available power so that nodes with extra energy help keep others stable. By taking advantage of low-latency, secure transactions with lightweight, intelligent contracts, the system maintains high scalability for more extensive networks with minimum communication overhead. The blockchain-based solution is ideal for secure, mission-critical applications. It improves energy autonomy and security for applications such as smart cities, environmental monitoring, and precision agriculture. It promotes dependable energy management in resource-constrained contexts by ensuring decentralized and tamper-resistant transactions. Finally, the WSNs will be more sustainable when combined with renewable energy harvesting techniques to enable longer-term operation without human intervention. Further research could examine the validity of this protocol under more varied environmental conditions and employ advanced machine learning algorithms to predict dynamic energy constraints or optimize.

Author Contributions

Conceptualization was carried out by U.D. and T.A., with S.Y. leading the methodology. Software development was handled by S.Y., while validation was performed by T.A., M.A. and S.Y. Formal analysis was conducted by T.A. and M.H., and the investigation was led by M.A. Resources were provided by E.-H.M.A., and data curation was managed by M.H. The original draft was prepared by U.D., with M.A. contributing to the review and editing process. Visualization was overseen by M.H., with supervision provided by E.-H.M.A. Project administration was managed by M.A., and funding acquisition was secured by E.-H.M.A. All authors have read and agreed to the published version of the manuscript.

Funding

This work is supported by a research grant from the Research, Development, and Innovation Authority (RDIA), Saudi Arabia, grant no. 13010-Tabuk-2023-UT-R-3-1-SE.

Data Availability Statement

The data, models, or codes that support the findings of this study are available from the corresponding author upon request.

Acknowledgments

This work is supported by a research grant from the Research, Development, and Innovation Authority (RDIA), Saudi Arabia, grant no. 13010-Tabuk-2023-UT-R-3-1-SE.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Alshmeel, G.H.A.; Al-Doori, A.S.B.; Ahmed, S.R.; Ibrahim, Z.A.; Ghaffoori, A.J.; Hussain, A.S.T. Self-Sustaining Buoy System: Harnessing Water Wave Energy for Smart, Wireless Sensing and Data Transmission. In Proceedings of the Cognitive Models and Artificial Intelligence Conference, İstanbul, Turkiye, 25–26 May 2024; pp. 349–356. [Google Scholar]
  2. Ismail, S.; Dawoud, D.W.; Reza, H. Securing wireless sensor networks using machine learning and Blockchain: A review. Future Internet 2023, 15, 200. [Google Scholar] [CrossRef]
  3. Dipon, W.H. Self-Sustaining Multi-Sensing and Wireless Communication System Powered by Efficient Energy Harvesting from Road Traffic and Heat. Ph.D. Thesis, The University of Texas at San Antonio, San Antonio, TX, USA, 2023. [Google Scholar]
  4. Arachchige, K.G.; Branch, P.; But, J. Evaluation of Correlation between Temperature of IoT Microcontroller Devices and Blockchain Energy Consumption in Wireless Sensor Networks. Sensors 2023, 23, 6265. [Google Scholar] [CrossRef] [PubMed]
  5. Qaragoez, Y.; Pollin, S.; Schreurs, D. Integrated Dual-Mode Energy Harvesting for Self-Sustaining Sensor Nodes: Synergy of Solar and RF Energies. In Proceedings of the 2024 IEEE/MTT-S International Microwave Symposium-IMS, Washington, DC, USA, 16–21 June 2024; IEEE: New York, NY, USA, 2024; pp. 273–276. [Google Scholar]
  6. Huang, X.; Zhao, W.; Yuan, M.; Sun, K.; Yang, B. A self-sustaining wireless sensing and flight control device for beetles. AIP Adv. 2024, 14, 095006. [Google Scholar] [CrossRef]
  7. Sivasankar, C.; Subramanian, E.K.; Sarala, V.; Moorthy, A.; Purushothaman, N. Optimizing Power Consumption in Wireless Sensor Networks for Prolonged Sustainability. In Proceedings of the 2024 Second International Conference on Advances in Information Technology (ICAIT), Karnataka, India, 24–27 July 2024; IEEE: New York, NY, USA, 2024; Volume 1, pp. 1–4. [Google Scholar]
  8. Ravikumar, C.V.; Sathish, K.; Su, C. Design and Analysis of Piezoelectric Energy Harvester for Wireless Sensor Networks. In Proceedings of the International Conference on Data Security and Privacy Protection, Xi’an, China, 25 October 2024; Springer Nature: Singapore, 2024; pp. 239–254. [Google Scholar]
  9. Paulraj, D.; Lavanya, R.; Jayasudha, T.; Niranjana, M.I.; Daniya, T.; Shadrach, F.D. Blockchain-based wireless sensor network security through authentication and cluster head selection. In Proceedings of the 2023 IEEE International Conference on Integrated Circuits and Communication Systems (ICICACS), Raichur, India, 24–25 February 2023; IEEE: New York, NY, USA, 2023; pp. 1–5. [Google Scholar]
  10. Draz, U.; Ali, T.; Yasin, S.; Naseer, N.; Waqas, U. A parametric performance evaluation of SMDBRP and AEDGRP routing protocols in an underwater wireless sensor network for data transmission. In Proceedings of the 2018 International Conference on Advancements in Computational Sciences (ICACS), Lahore, Pakistan, 19–21 February 2018; pp. 1–8. [Google Scholar]
  11. Zhou, X.; Huang, Z.; Xiao, K. Remote radio frequency unit selection of self-sustaining distributed base-station system based on downlink physical layer secure transmission. Wirel. Netw. 2024, 1–13. [Google Scholar] [CrossRef]
  12. Hussain, M.N.; Kader, K.A.; Ali, M.S.; Ullah, A.; Al Dodaev, Z. An Extensive Analysis of the Significance and Difficulties of Microgrids Based on Renewable Energy in Wireless Sensor Networks. Control. Syst. Optim. Lett. 2024, 2, 178–183. [Google Scholar] [CrossRef]
  13. Bentivogli, A.; Polonelli, T.; Magno, M.; Comai, G. Check for Enabling Predictive Maintenance on Electric Motors Through a Self-sustainable Wireless Sensor Node. Appl. Electron. Pervading Ind. Environ. Soc. Apple Pies 2022, 1036, 3. [Google Scholar]
  14. Ning, T.; Lin, C.; Cai, G.; Xie, K.; He, J.; Huang, C.; Debbah, M.R. Energy Buffer-Aided Wireless-Powered Relaying System for Self-Sustainable Implant WBAN. IEEE Open J. Commun. Soc. 2024, 5, 2302–2318. [Google Scholar] [CrossRef]
  15. Mayer, P.; Magno, M.; Benini, L. Self-sustaining ultrawideband positioning system for event-driven indoor localization. IEEE Internet Things J. 2023, 11, 1272–1284. [Google Scholar] [CrossRef]
  16. Shokoor, F.; Shafik, W. Harvesting energy overview for sustainable wireless sensor networks. J. Smart Cities Soc. 2023, 1–16. [Google Scholar] [CrossRef]
  17. Srividya, P. Self-Powered Wireless Sensor Networks in Cyber-Physical System. Self-Powered Cyber-Phys. Syst. 2023, 41–56. [Google Scholar]
  18. Khan, Z.A.; Amjad, S.; Ahmed, F.; Almasoud, A.M.; Imran, M.; Javaid, N. A blockchain-based deep-learning-driven architecture for quality routing in wireless sensor networks. IEEE Access 2023, 11, 31036–31051. [Google Scholar] [CrossRef]
  19. Diener, M.; Orman, A. Bbap-win: A new blockchain-based authentication protocol for wireless sensor networks. Appl. Sci. 2023, 13, 1526. [Google Scholar] [CrossRef]
  20. Faisal, M.; Husnain, G. Blockchain-Based Multi-hop Routing and Cost-Effective Decentralized Storage System for Wireless Sensor Networks. Wirel. Pers. Commun. 2023, 131, 3009–3025. [Google Scholar] [CrossRef]
  21. Draz, U.; Ali, T.; Yasin, S.; Waqas, U.; Rafiq, U. EADSA: Energy-aware distributed sink algorithm for hotspot problem in wireless sensor and actor networks. In Proceedings of the 2019 International Conference on Engineering and Emerging Technologies (ICEET), Lahore, Pakistan, 21–22 February 2019; pp. 1–6. [Google Scholar]
  22. Almasabi, S.; Shaf, A.; Ali, T.; Zafar, M.; Irfan, M.; Alsuwian, T. Securing smart grid data with Blockchain and wireless sensor networks: A collaborative approach. IEEE Access 2024, 12, 19181. [Google Scholar] [CrossRef]
  23. Rajaram, V.; Pandimurugan, V.; Rajasoundaran, S.; Rodrigues, P.; Kumar, S.S.; Selvi, M.; Loganathan, V. Enriched energy-optimized LEACH protocol for efficient data transmission in a wireless sensor network. Wirel. Netw. 2024, 31, 1–16. [Google Scholar] [CrossRef]
  24. Draz, U.; Yasin, S.; Ali, A.; Khan, M.A.; Nawaz, A. Traffic agents-based analysis of hotspot effect in IoT-enabled wireless sensor network. In Proceedings of the 2021 International Bhurban Conference on Applied Sciences and Technologies (IBCAST), Islamabad, Pakistan, 12–16 January 2021; pp. 1029–1034. [Google Scholar]
  25. Fu, X.; Pace, P.; Aloi, G.; Li, W.; Fortino, G. Toward robust and energy-efficient clustering wireless sensor networks: A double-stage scale-free topology evolution model. Comput. Netw. 2021, 200, 108521. [Google Scholar] [CrossRef]
  26. Lilhore, U.K.; Khalaf, O.I.; Simaiya, S.; Tavera Romero, C.A.; Abdulsahib, G.M.; Kumar, D. A depth-controlled and energy-efficient routing protocol for underwater wireless sensor networks. Int. J. Distrib. Sens. Netw. 2022, 18, 15501329221117118. [Google Scholar] [CrossRef]
  27. Sathish Kumar, L.; Ahmad, S.; Routray, S.; Prabu, A.V.; Alharbi, A.; Alouffi, B.; Rajasoundaran, S. Modern Energy Optimization Approach for Efficient Data Communication in IoT-Based Wireless Sensor Networks. Wirel. Commun. Mob. Comput. 2022, 2022, 7901587. [Google Scholar] [CrossRef]
  28. Prakash, V.; Singh, D.; Pandey, S.; Singh, S.; Singh, P.K. Energy-Optimization Route and Cluster Head Selection Using M-PSO and GA in Wireless Sensor Networks. Wirel. Pers. Commun. 2024, 1–26. [Google Scholar] [CrossRef]
  29. Bahadur, D.J.; Lakshmanan, L. A novel method for optimizing energy consumption in wireless sensor networks using genetic algorithm. Microprocess. Microsyst. 2023, 96, 104749. [Google Scholar] [CrossRef]
  30. Draz, U.; Ali, T.; Asghar, K.; Yasin, S.; Sharif, Z.; Abbas, Q.; Aman, S. A Comprehensive Comparative Analysis of Two Novel Underwater Routing Protocols. Int. J. Adv. Comput. Sci. Appl. 2019, 10. [Google Scholar] [CrossRef]
  31. Han, Y.; Byun, H.; Zhang, L. Energy-balanced cluster-routing protocol based on particle swarm optimization with five mutation operators for wireless sensor networks. Sensors 2020, 20, 7217. [Google Scholar] [CrossRef] [PubMed]
  32. Ali, T.; Yasin, S.; Draz, U.; Ayaz, M. Towards formal modelling of subnet-based hotspot algorithm in wireless sensor networks. Wirel. Pers. Commun. 2019, 107, 1573–1606. [Google Scholar] [CrossRef]
  33. Draz, U.; Ali, T.; Yasin, S.; Fareed, A.; Shahbaz, M. Watchman-based data packet forwarding algorithm for underwater wireless sensor and actor networks. In Proceedings of the 2019 International Conference on Electrical, Communication, and Computer Engineering (ICECCE), Swat, Pakistan, 24–25 July 2019; IEEE: New York, NY, USA, 2019; pp. 1–7. [Google Scholar]
  34. Kathiroli, P.; Selvadurai, K. Energy-efficient cluster head selection using improved Sparrow Search Algorithm in Wireless Sensor Networks. J. King Saud Univ.-Comput. Inf. Sci. 2022, 34, 8564–8575. [Google Scholar] [CrossRef]
  35. Kadhim Mohammed, L.A.; Hasan, A.M.; Hamza, E.K. Pruning and Validation Techniques Enhanced Genetic Algorithm for Energy Efficiency in Wireless Sensor Networks. Ingénierie Des Systèmes D’inform. 2024, 29, 1305. [Google Scholar] [CrossRef]
  36. Senkumar, M.R.; Arafat, I.S.; Nathiya, R.; Nishath, S.M. Enhanced Energy Efficient Clustering and Routing Algorithm in Wireless Sensor Network. Wirel. Pers. Commun. 2024, 1–28. [Google Scholar] [CrossRef]
  37. Takale, D.G.; Mahalle, P.N.; Gawali, P.P.; Deshmukh, G.B.; Banchhor, C.O.; Mehta, P.S. Innovative and Sustainable Energy-Efficient Wireless Sensor Networks: Design and Techniques. In Edge Computational Intelligence for AI-Enabled IoT Systems; CRC Press: Boca Raton, FL, USA, 2024; pp. 281–319. [Google Scholar]
  38. Suman, M.A.N.; Geethasri, V.; Pavan, A.S. A Routing Protocol for Efficiently Managing Energy In Underwater Wireless Sensor Networks with Depth Control. J. Sci. Technol. 2024, 9, 59–73. [Google Scholar]
  39. Zhong, C.; Chen, X.; Zhang, Z.; Karagiannidis, G.K. Wireless-powered communications: Performance analysis and optimization. IEEE Trans. Commun. 2015, 63, 5178–5190. [Google Scholar] [CrossRef]
  40. Kumar, D. Performance analysis of energy efficient clustering protocols for maximising lifetime of wireless sensor networks. IET Wirel. Sens. Syst. 2014, 4, 9–16. [Google Scholar] [CrossRef]
  41. Ferrag, M.A.; Shu, L. The performance evaluation of blockchain-based security and privacy systems for the Internet of Things: A tutorial. IEEE Internet Things J. 2021, 8, 17236–17260. [Google Scholar] [CrossRef]
  42. Baltaci, A.; Dinc, E.; Ozger, M.; Alabbasi, A.; Cavdar, C.; Schupke, D. A survey of wireless networks for future aerial communications (FACOM). IEEE Commun. Surv. Tutor. 2021, 23, 2833–2884. [Google Scholar] [CrossRef]
  43. Kanade, A.; Ranganthan, C.S.; Babu, A.J.; Ramachandran, G.; Kusuma, A.K.; Anand, M.; Reddy, L.D.V. Analysis of wireless network security in internet of things and its applications. Indian J. Eng. 2024, 21, e1ije1675. [Google Scholar] [CrossRef]
  44. Xu, M.; Du, H.; Niyato, D.; Kang, J.; Xiong, Z.; Mao, S.; Han, Z.; Jamalipour, A.; Kim, D.I.; Shen, X.; et al. Unleashing the power of edge-cloud generative ai in mobile networks: A survey of aigc services. IEEE Commun. Surv. Tutor. 2024, 26, 1127–1170. [Google Scholar] [CrossRef]
  45. Rehman, A.; Abdullah, S.; Fatima, M.; Iqbal, M.W.; Almarhabi, K.A.; Ashraf, M.U.; Ali, S. Ensuring security and energy efficiency of wireless sensor network by using blockchain. Appl. Sci. 2022, 12, 10794. [Google Scholar] [CrossRef]
  46. Chithaluru, P.; Al-Turjman, F.; Stephan, T.; Kumar, M.; Mostarda, L. Energy-efficient blockchain implementation for cognitive wireless communication networks (CWCNs). Energy Rep. 2021, 7, 8277–8286. [Google Scholar] [CrossRef]
  47. Hanggoro, D.; Windiatmaja, J.H.; Muis, A.; Sari, R.F.; Pournaras, E. Energy-aware Proof-of-Authority: Blockchain Consensus for Clustered Wireless Sensor Network. Blockchain Res. Appl. 2024, 5, 100211. [Google Scholar] [CrossRef]
  48. Shahbazi, Z.; Byun, Y.C. Towards a secure thermal-energy aware routing protocol in wireless body area network based on blockchain technology. Sensors 2020, 20, 3604. [Google Scholar] [CrossRef]
  49. Jabor, M.S.; Azez, A.S.; Campelo, J.C.; Bonastre Pina, A. New approach to improve power consumption associated with blockchain in WSNs. PLoS ONE 2023, 18, e0285924. [Google Scholar] [CrossRef]
  50. Heinzelman, W.B.; Chandrakasan, A.P.; Balakrishnan, H. Energy-efficient communication protocol for wireless microsensor networks. IEEE Trans. Wirel. Commun. 2023, 22, 1456–1468. [Google Scholar]
  51. Yazid, Y.; Guerrero-González, A.; Ez-Zazi, I.; El Oualkadi, A.; Arioua, M. A Reinforcement Learning Based Transmission Parameter Selection and Energy Management for Long Range Internet of Things. Sensors 2022, 22, 5662. [Google Scholar]
  52. Singh, R.; Kaur, J.; Verma, S. Blockchain-enhanced energy optimization in wireless sensor networks. IEEE Access 2024, 12, 34567–34578. [Google Scholar]
  53. Alam, K.S.; Kaif, A.D.; Das, S.K. A blockchain-based optimal peer-to-peer energy trading framework for decentralized energy management with in a virtual power plant: Lab scale studies and large scale proposal. Appl. Energy 2024, 365, 123243. [Google Scholar] [CrossRef]
  54. Al-Saedi, A.A.; Boeva, V.; Casalicchio, E.; Exner, P. Context-Aware Edge-Based AI Models for Wireless Sensor Networks—An Overview. Sensors 2022, 22, 5544. [Google Scholar] [CrossRef] [PubMed]
  55. Maity, P.; Srivastava, S.; Rajput, K.P.; Venkategowda, N.K.; Jagannatham, A.K.; Hanzo, L. Hybrid Precoder and Combiner Designs for Decentralized Parameter Estimation in mmWave MIMO Wireless Sensor Networks. IEEE Internet Things J. 2023, 11, 1629–1643. [Google Scholar] [CrossRef]
Figure 1. Blockchain-driven energy swapping with LSTM prediction in wireless sensor networks (WSNs).
Figure 1. Blockchain-driven energy swapping with LSTM prediction in wireless sensor networks (WSNs).
Mathematics 13 00395 g001
Figure 2. Comparative analysis of communication overhead with different energy management protocols for scaling wireless sensor networks.
Figure 2. Comparative analysis of communication overhead with different energy management protocols for scaling wireless sensor networks.
Mathematics 13 00395 g002
Figure 3. Comparative analysis of network lifetime with different energy management protocols.
Figure 3. Comparative analysis of network lifetime with different energy management protocols.
Mathematics 13 00395 g003
Figure 4. Comparative analysis of energy loss over time: BDSES-WSN outperforms other protocols in minimizing energy wastage.
Figure 4. Comparative analysis of energy loss over time: BDSES-WSN outperforms other protocols in minimizing energy wastage.
Mathematics 13 00395 g004
Figure 5. Comparative analysis of transaction latency versus network size in four energy management protocols, demonstrating the superior efficiency of the BDSES-WSN (blockchain-based energy swapping) protocol in maintaining lower latency as network size increases.
Figure 5. Comparative analysis of transaction latency versus network size in four energy management protocols, demonstrating the superior efficiency of the BDSES-WSN (blockchain-based energy swapping) protocol in maintaining lower latency as network size increases.
Mathematics 13 00395 g005
Figure 6. Comparative analysis of energy efficiency over time across four energy management protocols, showcasing the superior long-term energy efficiency of BDSES-WSN (blockchain-based energy swapping) compared to other protocols, particularly in extended network operations.
Figure 6. Comparative analysis of energy efficiency over time across four energy management protocols, showcasing the superior long-term energy efficiency of BDSES-WSN (blockchain-based energy swapping) compared to other protocols, particularly in extended network operations.
Mathematics 13 00395 g006
Figure 7. Blockchain’s impact on transactional security, demonstrating that secure transactions increase linearly with no incidents of tampering observed, highlighting blockchain’s robustness in preventing tampered transactions.
Figure 7. Blockchain’s impact on transactional security, demonstrating that secure transactions increase linearly with no incidents of tampering observed, highlighting blockchain’s robustness in preventing tampered transactions.
Mathematics 13 00395 g007
Figure 8. Comparison of energy consumption between Proof-of-Work (PoW) and Proof-of-Stake (PoS) consensus mechanisms, highlighting the significantly higher energy efficiency of PoS due to its less computationally intensive validation process.
Figure 8. Comparison of energy consumption between Proof-of-Work (PoW) and Proof-of-Stake (PoS) consensus mechanisms, highlighting the significantly higher energy efficiency of PoS due to its less computationally intensive validation process.
Mathematics 13 00395 g008
Figure 9. Comparison of the optimized energy distribution before and after trading, illustrating how energy trading reduces variability and enhances efficiency by balancing energy levels across the system.
Figure 9. Comparison of the optimized energy distribution before and after trading, illustrating how energy trading reduces variability and enhances efficiency by balancing energy levels across the system.
Mathematics 13 00395 g009
Figure 10. Impact of environmental conditions on node lifetime: Comparing the effectiveness of BDSES-WSN (energy swapping) and traditional methods, showing improved node lifetimes with energy swapping across varying temperature and humidity conditions.
Figure 10. Impact of environmental conditions on node lifetime: Comparing the effectiveness of BDSES-WSN (energy swapping) and traditional methods, showing improved node lifetimes with energy swapping across varying temperature and humidity conditions.
Mathematics 13 00395 g010
Figure 11. Real-time energy usage vs. harvested energy: dynamic adjustments for efficient energy management in WSN nodes.
Figure 11. Real-time energy usage vs. harvested energy: dynamic adjustments for efficient energy management in WSN nodes.
Mathematics 13 00395 g011
Table 1. Comprehensive overview of recent studies on energy efficiency, security, and blockchain integration in wireless sensor networks (WSNs).
Table 1. Comprehensive overview of recent studies on energy efficiency, security, and blockchain integration in wireless sensor networks (WSNs).
Ref.Study FocusAlgorithm/TechniqueApplication DomainKey ContributionLimitationPerformance Metrics
[1]Self-sustaining buoy systemWater wave energy harvestingSmart, wireless sensingUses water wave energy for data transmissionLimited to specific environmentsEnergy efficiency (moderate), no blockchain
[2]Securing WSNs using ML and BlockchainMachine learning, blockchainWSNsUses ML and blockchain for secure WSN communicationDoes not focus on energy managementTransaction security (high), energy optimization (low)
[3]Self-sustaining multi-sensing systemEnergy harvesting from road trafficWSNsEfficient energy harvesting from traffic and heat sourcesLimited to specific environmentsEnergy efficiency (high), no blockchain integration
[4]Temperature and blockchain energy consumptionCorrelation analysisIoT microcontroller devicesAnalyzes temperature effects on blockchain energy consumptionFocuses on correlation, not energy optimizationLatency (low), no energy trading mechanism
[5]Dual-mode energy harvestingSolar and RF energy harvestingSelf-sustaining sensor nodesIntegrates solar and RF energy harvestingLimited to solar and RF energy sourcesEnergy efficiency (high), no blockchain-based management
[6]Self-sustaining wireless sensing for beetlesEnergy harvesting for flight controlWireless sensingUses energy harvesting for wireless flight control in beetlesLimited to biological systemsEnergy efficiency (low), no security implementation
[9]Blockchain-based WSN securityBlockchain, cluster head selectionWSNsUses blockchain for WSN security through cluster head selectionNo energy optimization addressedTransaction security (high), no energy management
[18]Blockchain-based deep learning for WSN routingBlockchain, deep learningWSNsUses blockchain and deep learning for quality routing in WSNsFocuses on routing, not energy managementTransaction security (high), latency (moderate)
[20]Blockchain-based routing and storage for WSNsBlockchain, multi-hop routingWSNsEnhanced routing efficiency and secure decentralized storageDoes not focus on energy managementLatency (low), no energy trading mechanism
[27]Energy optimization in IoT-based WSNsModern energy optimization approachIoT-based WSNsOptimized energy-efficient data communicationDoes not address blockchain for energy tradingEnergy efficiency (high), no blockchain integration
[28]Energy-optimization route and cluster selectionPSO and GAWSNsOptimized route and cluster head selectionNo energy trading mechanism is includedEnergy efficiency (moderate), no blockchain
Table 2. Optimal hyperparameters for wireless sensor network (WSN) node configuration, blockchain-based energy swapping, LSTM neural network, and energy harvesting models.
Table 2. Optimal hyperparameters for wireless sensor network (WSN) node configuration, blockchain-based energy swapping, LSTM neural network, and energy harvesting models.
ModelHyperparameterOptimal Parameters
WSN Node ConfigurationNumber of Nodes1000
Initial Node Energy10 J
Energy Threshold (E-threshold)2 J
Communication Energy Consumption0.05 J/packet
Sensing Energy Consumption0.02 J/sensor cycle
Processing Energy Consumption0.01 J/operation
Harvesting Energy RateSolar: 0.5 W, RF: 0.3 W
Blockchain-Based Energy SwappingConsensus AlgorithmProof-of-Stake (PoS)
Number of Validators50
Transaction Fee0.1% of traded energy
Block Size2 MB
Validation Time2 s
LSTM Neural Network (Energy Prediction)Number of Layers3
Number of Neurons per Layer64
Activation FunctionReLU
OptimizerAdam
Learning Rate0.0005
Sequence Length100
Energy Harvesting ModelSolar Conversion Efficiency20%
RF Energy Conversion Efficiency15%
Maximum Harvesting Capacity5 W
Integration StrategyWeight Adjustment FactorAdaptive
Fitness Function Weightsα = 0.6, β = 0.4
Threshold for Convergence10−4
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

Draz, U.; Ali, T.; Yasin, S.; Hijji, M.; Ayaz, M.; Aggoune, E.-H.M. Decentralized Energy Swapping for Sustainable Wireless Sensor Networks Using Blockchain Technology. Mathematics 2025, 13, 395. https://doi.org/10.3390/math13030395

AMA Style

Draz U, Ali T, Yasin S, Hijji M, Ayaz M, Aggoune E-HM. Decentralized Energy Swapping for Sustainable Wireless Sensor Networks Using Blockchain Technology. Mathematics. 2025; 13(3):395. https://doi.org/10.3390/math13030395

Chicago/Turabian Style

Draz, Umar, Tariq Ali, Sana Yasin, Mohammad Hijji, Muhammad Ayaz, and EL-Hadi M. Aggoune. 2025. "Decentralized Energy Swapping for Sustainable Wireless Sensor Networks Using Blockchain Technology" Mathematics 13, no. 3: 395. https://doi.org/10.3390/math13030395

APA Style

Draz, U., Ali, T., Yasin, S., Hijji, M., Ayaz, M., & Aggoune, E.-H. M. (2025). Decentralized Energy Swapping for Sustainable Wireless Sensor Networks Using Blockchain Technology. Mathematics, 13(3), 395. https://doi.org/10.3390/math13030395

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