## 3 Peer-to-Peer Energy Trading
### Smart Contracts in Energy Sector Applications
#### 3.4.2 Energy Sector Applications  
Applications of Smart Contracts for Energy. After discussing the primary characteristics and advantages of smart contracts and the methodology and actions required to execute them, we examine their claimed energy consumption. Two innovative contract applications are left-side control and flexibility and right-side distributed control and flexibility. The most apparent application is trade and payment because intelligent contracts operate on a blockchain created for financial transactions. Typically, smart contracts are utilized in energy or flexibility trading studies. In these applications, smart contracts facilitate the matching of consumers (offering microgeneration and/or storage) and recommend a safe payment or settlement mechanism [101]. Figure 7: Infrastructure-based energy trading. In [102], the authors developed a P2P power trading system using Ethereum smart contracts. The smart contract resides on a shared blockchain, ensuring accurate transaction execution and immutable transaction records. It eliminates the high costs and overheads of typical server-based P2P power transmission systems. Dynamic pricing for automatic balancing of aggregate supply and aggregate demand within a small network, double selling prevention, intuitive and independent running, test base experience (Node.js and web3.js API to access Ethereum Virtual Machine on Raspberry Pi with MATLAB interface) and simulation via characters are the main features for implementation (default consumers and persistent consumers of the standard). In the following, we describe the primary state schemes and implementation methods. In [103], the authors mention that smart contracts serve as the basis for distributed blockchain applications. The authors highlight that intelligent contract adaptation is not available, and source code reuse is limited to cloning. For this reason, the authors discuss the architecture and implementation of the smart contract with precise validation rules. First, update the list of smart contract validation criteria at runtime to set the distinct transaction types. Second, it is possible to reuse validation rules across smart contract configurations. Using UML models that are independent of the blockchain, smart contracts and validation rules are developed. Java was used to implement the pattern. The design controls are inherited through polymorphism and sealed classes, assigning them only to final classes. This approach facilitates the reuse of smart contracts and security. Due to the reusability of the test class between smart contract configurations, the announced validation requirements improve test automation and reduce test preparation effort. The exchange of renewable energy within the consumer group and between cultures refers to the pattern of consumption. In [104], the authors note that microscopic renewable energy production is rising, resulting in consumption patterns in society that allow for energy surplus and consumption flexibility. Peer-to-peer energy trading requires an immutable decentralized system, and access is controlled for token energy assets. Consumers, electric vehicles, energy companies and storage providers can use a unified blockchain-based system to trade energy assets. Hyperledger Fabric supports two versions of the system. Non-fungible (NFT) tokens encapsulate a unique identifier or information and value, while fungible tokens represent value (FT) only. We have created and tested ways to manage the token lifecycle in smart contracts. In [105], the authors state that demand response (DR) services can enhance renewable energy penetration by controlling load usage and system balancing. The success of industries, societies and consumers that provide and integrate load flexibility into energy markets will depend on redesigning and adapting existing stakeholder relationships.