Reconfigurable Smart Contracts for Renewable Energy Exchange with Re-Use of Verification Rules
Abstract
:1. Introduction
- Smart Contract Design Pattern (SCDP)—the pattern for design and development of verification rules in smart contracts, which is blockchain platform independent.
- The UML profile—the new version of UML Profile for Smart Contracts that encompasses stereotypes for both smart contract’s abstraction levels: blockchain platform-independent and blockchain platform-specific. The latter level as for now encompasses stereotypes only for the R3 Corda permissioned distributed ledger.
- Pattern’s implementation—new, blockchain platform-independent implementation in Java language v. 18 that encompasses the smart contract reconfigurability option.
- Testing method—defined rules for unit tests with the formula that specifies the number of test cases, which hinges on the number of verification rules and the construction of evaluation expression and applied logical operators. Automated tests for a smart contract and verification rules were prepared in JUnit v. 5.7.0.
- Definitions of verification rule, evaluation expression, and smart contract configuration.
- Illustrative example of the design of a smart contract—the example uses new modeling means and design of the pattern.
2. Related Work
3. Renewable Energy Example
- TechnicalVR1—transaction can be executed within the same community;
- TechnicalVR2—transaction can be executed between different prosumers;
- BusinessVR1—quantity of energy to transfer must be greater than zero;
- BusinessVR2—source prosumer surplus of energy must be greater than or equal to the quantity of energy to transfer;
- BusinessVR3—the sum of renewable energy generation and battery energy surplus is smaller than the energy need;
- BusinessVR4—battery energy surplus is equal to zero;
- ExpandingVR1—always return true;
- TechnicalVR1Extended—transaction can be executed between various communities;
- ExpandingVR1Extended—target prosumer need for energy must be greater than or equal to the quantity of energy to transfer.
- C—number of configurations in a smart contract,
- —number of re-used verification rules in i-th configuration of the smart contract,
- —number of verification rules in i-th configuration of the smart contract.
4. UML Profile for Smart Contracts
- ≪AbstractSContract≫—used for marking an abstract, generic class of smart contract. The class is a superclass for all types of concrete smart contracts;
- ≪AbstractVRule≫—used for marking an abstract, generic interface of verification rule. The interface must be implemented by concrete verification rules;
- ≪SContract≫—used for marking concrete smart contract classes. This means the agreement that regulates the cooperation of blockchain nodes;
- ≪VRule≫—used for marking concrete verification rules classes. This means a concrete condition that must be met in the smart contract.
- ≪State≫—an object that is stored in blockchain nodes. Comprises the quantity exchanged and references to both parties: producer and buyer.
- ≪Flow≫—the procedure of reconciliation transactions and cooperation among nodes.
5. The Pattern Design
6. The Pattern Implementation
- Contracts—the package consists of the SmartContract abstract class and one the ExchangeEnergyContract class for concrete smart contract;
- Rules—the package encompasses the VerificationRule interface and subpackages:
- —
- exchangeEnergy—contains concrete verification rules classes, i.e.: TechnicalVR1, TechnicalVR2, BusinessVR1, BusinessVR2, and ExpandingVR1;
- —
- crossCommunity—contains concrete extended verification rules classes for cross community energy exchange, i.e., TechnicalVR1Extended; ExpandingVR1Extended.
6.1. Energy Exchange in the Same Community
6.2. Cross-Community Energy Exchange
6.3. Smart Contract Reconfigurability
6.4. Transaction Types
6.5. Buying Energy from Energy Grid
7. Tests
- S—number of smart contracts;
- V—number of active verification rules;
- —number of configurations in i-th smart contract;—number of active verification rules in j-th configuration of i-th smart contract.
8. Discussion and Limitations
9. Conclusions
Funding
Conflicts of Interest
References
- Casino, F.; Dasaklis, T.K.; Patsakis, C. A systematic literature review of blockchain-based applications: Current status, classification and open issues. Telemat. Inform. 2019, 36, 55–81. [Google Scholar] [CrossRef]
- Xu, X.; Weber, I.; Staples, M. Architecture for Blockchain Applications; Springer: Cham, Switzerland, 2019; pp. 5–7. [Google Scholar] [CrossRef]
- Polge, J.; Robert, J.; Le Traon, Y. Permissioned blockchain frameworks in the industry: A comparison. ICT Express 2021, 7, 229–233. [Google Scholar] [CrossRef]
- Neethirajan, S.; Kemp, B. Digital Livestock Farming. Sens. Bio-Sens. Res. 2021, 32, 100408. [Google Scholar] [CrossRef]
- Lucas, A.; Geneiatakis, D.; Soupionis, Y.; Nai-Fovino, I.; Kotsakis, E. Blockchain Technology Applied to Energy Demand Response Service Tracking and Data Sharing. Energies 2021, 14, 1881. [Google Scholar] [CrossRef]
- Java v.18 Documentation. Available online: https://docs.oracle.com/en/java/javase/18/ (accessed on 18 April 2022).
- Sund, T.; Lööf, C.; Nadjm-Tehrani, S.; Asplund, M. Blockchain-based event processing in supply chains—A case study at IKEA. Robot. Comput. Integr. Manuf. 2020, 65, 101971. [Google Scholar] [CrossRef]
- Solidity v.0.8.13 Documentation. Available online: https://docs.soliditylang.org/en/v0.8.13/ (accessed on 18 April 2022).
- Hyperlegder Fabric. Available online: https://www.hyperledger.org/use/fabric (accessed on 15 April 2022).
- Corda. Available online: https://www.corda.net (accessed on 15 April 2022).
- Quorum. Available online: https://consensys.net/quorum/ (accessed on 15 April 2022).
- Yapa, C.; de Alwis, C.; Liyanage, M.; Ekanayake, J. Survey on blockchain for future smart grids: Technical aspects, applications, integration challenges and future research. Energy Rep. 2021, 7, 6530–6564. [Google Scholar] [CrossRef]
- Wu, H.; Cao, J.; Yang, Y.; Tung, C.L.; Jiang, S.; Tang, B.; Liu, Y.; Wang, X.; Deng, Y. Data management in supply chain using blockchain: Challenges and a case study. In Proceedings of the 2019 28th International Conference on Computer Communication and Networks (ICCCN), Valencia, Spain, 29 July–1 August 2019; pp. 1–8. [Google Scholar] [CrossRef]
- Jiang, S.; Cao, J.; Wu, H.; Yang, Y.; Ma, M.; He, J. BlocHIE: A BLOCkchain-Based Platform for Healthcare Information Exchange. In Proceedings of the 2018 IEEE International Conference on Smart Computing (SMARTCOMP), Taormina, Sicily, Italy, 18–20 June 2018; pp. 49–56. [Google Scholar] [CrossRef]
- Ante, L.; Steinmetz, F.; Fiedler, I. Blockchain and energy: A bibliometric analysis and review. Renew. Sustain. Energy Rev. 2021, 137, 110597. [Google Scholar] [CrossRef]
- Guo, Y.; Wan, Z.; Cheng, X. When Blockchain Meets Smart Grids: A Comprehensive Survey. High-Confid. Comput. 2022, 2, 100059. [Google Scholar] [CrossRef]
- Kirli, D.; Couraud, B.; Robu, V.; Salgado-Bravo, M.; Norbu, S.; Andoni, M.; Antonopoulos, I.; Negrete-Pincetic, M.; Flynn, D.; Kiprakis, A. Smart contracts in energy systems: A systematic review of fundamental approaches and implementations. Renew. Sustain. Energy Rev. 2022, 158, 112013. [Google Scholar] [CrossRef]
- Wang, S.; Taha, A.F.; Wang, J.; Kvaternik, K.; Hahn, A. Energy Crowdsourcing and Peer-to-Peer Energy Trading in Blockchain-Enabled Smart Grids. IEEE Trans. Syst. Man Cybern. Syst. 2019, 49, 1612–1623. [Google Scholar] [CrossRef] [Green Version]
- Park, L.W.; Lee, S.; Chang, H. A Sustainable Home Energy Prosumer-Chain Methodology with Energy Tags over the Blockchain. Sustainability 2018, 10, 658. [Google Scholar] [CrossRef] [Green Version]
- Baggio, A.; Grimaccia, F. Blockchain as Key Enabling Technology for Future Electric Energy Exchange: A Vision. IEEE Access 2020, 8, 205250–205271. [Google Scholar] [CrossRef]
- Chantrel, S.P.M.; Surmann, A.; Erge, T.; Thomsen, J. Participative Renewable Energy Community—How Blockchain-Based Governance Enables a German Interpretation of RED II. Electricity 2021, 2, 471–486. [Google Scholar] [CrossRef]
- Yahaya, A.S.; Javaid, N.; Alzahrani, F.A.; Rehman, A.; Ullah, I.; Shahid, A.; Shafiq, M. Blockchain Based Sustainable Local Energy Trading Considering Home Energy Management and Demurrage Mechanism. Sustainability 2020, 12, 3385. [Google Scholar] [CrossRef] [Green Version]
- Saxena, S.; Farag, H.E.Z.; Brookson, A.; Turesson, H.; Kim, H. A Permissioned Blockchain System to Reduce Peak Demand in Residential Communities via Energy Trading: A Real-World Case Study. IEEE Access 2021, 9, 5517–5530. [Google Scholar] [CrossRef]
- Jamil, F.; Iqbal, N.; Imran; Ahmad, S.; Kim, D. Peer-to-Peer Energy Trading Mechanism Based on Blockchain and Machine Learning for Sustainable Electrical Power Supply in Smart Grid. IEEE Access 2021, 9, 39193–39217. [Google Scholar] [CrossRef]
- Son, Y.B.; Im, J.H.; Kwon, H.Y.; Jeon, S.Y.; Lee, M.K. Privacy-Preserving Peer-to-Peer Energy Trading in Blockchain-Enabled Smart Grids Using Functional Encryption. Energies 2020, 13, 1321. [Google Scholar] [CrossRef] [Green Version]
- Jiang, S.; Cao, J.; Wu, H.; Yang, Y. Fairness-Based Packing of Industrial IoT Data in Permissioned Blockchains. IEEE Trans. Ind. Inform. 2021, 17, 7639–7649. [Google Scholar] [CrossRef]
- Barros-Justo, J.L.; Benitti, F.B.V.; Matalonga, S. Trends in software reuse research: A tertiary study. Comput. Stand. Interfaces 2019, 66, 103352. [Google Scholar] [CrossRef]
- Papamichail, M.D.; Diamantopoulos, T.; Symeonidis, A.L. Measuring the reusability of software components using static analysis metrics and reuse rate information. J. Syst. Softw. 2019, 158, 110423. [Google Scholar] [CrossRef]
- De Meester, B.; Seymoens, T.; Dimou, A.; Verborgh, R. Implementation-independent function reuse. Future Gener. Comput. Syst. 2020, 110, 946–959. [Google Scholar] [CrossRef]
- Ma, Z.; Yuan, Z.; Yan, L. Two-level clustering of UML class diagrams based on semantics and structure. Inf. Softw. Technol. 2021, 130, 106456. [Google Scholar] [CrossRef]
- Makady, S.; Walker, R.J. Debugging and maintaining pragmatically reused test suites. Inf. Softw. Technol. 2018, 102, 6–29. [Google Scholar] [CrossRef]
- Pierro, G.A.; Tonelli, R.; Marchesi, M. An Organized Repository of Ethereum Smart Contracts’ Source Codes and Metrics. Future Internet 2020, 12, 197. [Google Scholar] [CrossRef]
- Kondo, M.; Oliva, G.A.; Jiang, Z.M.; Hassan, A.E.; Mizuno, O. Code cloning in smart contracts: A case study on verified contracts from the ethereum blockchain platform. Empirical Softw. Eng. 2020, 25, 4617–4675. [Google Scholar] [CrossRef]
- Zou, W.; Lo, D.; Kochhar, P.S.; Le, X.D.; Xia, X.; Feng, Y.; Chen, Z.; Xu, B. Smart Contract Development: Challenges and Opportunities. IEEE Trans. Softw. Eng. 2021, 47, 2084–2106. [Google Scholar] [CrossRef]
- Sánchez-Gómez, N.; Torres-Valderrama, J.; García-García, J.A.; Gutiérrez, J.J.; Escalona, M.J. Model-Based Software Design and Testing in Blockchain Smart Contracts: A Systematic Literature Review. IEEE Access 2020, 8, 164556–164569. [Google Scholar] [CrossRef]
- Hu, K.; Zhu, J.; Ding, Y.; Bai, X.; Huang, J. Smart Contract Engineering. Electronics 2020, 9, 2042. [Google Scholar] [CrossRef]
- Hamdaqa, M.; Met, L.A.P.; Qasse, I. iContractML 2.0: A domain-specific language for modeling and deploying smart contracts onto multiple blockchain platforms. Inf. Softw. Technol. 2022, 144, 106762. [Google Scholar] [CrossRef]
- Dwivedi, V.; Norta, A.; Wulf, A.; Leiding, B.; Saxena, S.; Udokwu, C. A Formal Specification Smart-Contract Language for Legally Binding Decentralized Autonomous Organizations. IEEE Access 2021, 9, 76069–76082. [Google Scholar] [CrossRef]
- Ozkaya, M.; Erata, F. A survey on the practical use of UML for different software architecture viewpoints. Inf. Softw. Technol. 2020, 121, 106275. [Google Scholar] [CrossRef]
- Jurgelaitis, M.; Čeponienė, L.; Butkienė, R. Solidity Code Generation From UML State Machines in Model-Driven Smart Contract Development. IEEE Access 2022, 10, 33465–33481. [Google Scholar] [CrossRef]
- Górski, T. The 1+5 Architectural Views Model in Designing Blockchain and IT System Integration Solutions. Symmetry 2021, 13, 2000. [Google Scholar] [CrossRef]
- UML Profile for Smart Contracts. Available online: https://github.com/drGorski/UMLProfile4SmartContracts (accessed on 15 April 2022).
- The SCDP Implementation in Java. Available online: https://github.com/drGorski/SmartContractDesignPattern (accessed on 15 April 2022).
- Pender, T. Customizing UML using profiles. In UML Bible; Wiley Publishing, Inc.: Indianapolis, IN, USA, 2003; pp. 687–723. [Google Scholar]
- OpenJDK JDK 18 General-Availability Release. Available online: https://jdk.java.net/18/ (accessed on 18 April 2022).
- Li, C.; Nie, S.; Cao, Y.; Yu, Y.; Hu, Z. Trace-Based Dynamic Gas Estimation of Loops in Smart Contracts. IEEE Open J. Comput. Soc. 2020, 1, 295–306. [Google Scholar] [CrossRef]
- Górski, T. Towards Continuous Deployment for Blockchain. Appl. Sci. 2021, 11, 11745. [Google Scholar] [CrossRef]
Use Case/Smart Contract Name | Configuration Name | Verification Rule Class |
---|---|---|
Exchange energy | In-community (Standard) | TechnicalVR1, TechnicalVR2, BusinessVR1, BusinessVR2, ExpandingVR1 |
Exchange energy | Cross-community | TechnicalVR1 Extended, TechnicalVR2, BusinessVR1, BusinessVR2, ExpandingVR1Extended |
Buy energy from Grid | Standard | TechnicalVR2, BusinessVR1, BusinessVR3, BusinessVR4 |
Name | UML | The Pattern Layer | Type |
---|---|---|---|
≪AbstractSContract≫ | Class | Abstract | Generic |
≪AbstractVRule≫ | Class, ≪Interface≫ | Abstract | Generic |
≪SContract≫ | Class | Concrete | Generic |
≪VRule≫ | Class | Concrete | Generic |
≪State≫ | Class | Concrete | R3 Corda |
≪Flow≫ | Class | Concrete | R3 Corda |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2022 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Górski, T. Reconfigurable Smart Contracts for Renewable Energy Exchange with Re-Use of Verification Rules. Appl. Sci. 2022, 12, 5339. https://doi.org/10.3390/app12115339
Górski T. Reconfigurable Smart Contracts for Renewable Energy Exchange with Re-Use of Verification Rules. Applied Sciences. 2022; 12(11):5339. https://doi.org/10.3390/app12115339
Chicago/Turabian StyleGórski, Tomasz. 2022. "Reconfigurable Smart Contracts for Renewable Energy Exchange with Re-Use of Verification Rules" Applied Sciences 12, no. 11: 5339. https://doi.org/10.3390/app12115339
APA StyleGórski, T. (2022). Reconfigurable Smart Contracts for Renewable Energy Exchange with Re-Use of Verification Rules. Applied Sciences, 12(11), 5339. https://doi.org/10.3390/app12115339