# Reconfigurable Smart Contracts for Renewable Energy Exchange with Re-Use of Verification Rules
## 1 Introduction  
Blockchain is a game-changing technology for various business uses. This is well illustrated by [PERSON] et al. [1], who in the literature review present the applications of the technology in various fields. Smart contracts were defined by [PERSON] et al. [2] as \"programs deployed as data in the blockchain ledger and executed in transactions on the blockchain.\" It can be indicated two primary types of blockchain frameworks: permissioned (also known as private) and permissionless (also called public). In the first type, only directly involved nodes realize a transaction, which preserves privacy and facilitates scalability. For those reasons, permissioned blockchain frameworks are widely deployed in diverse industries [3]. The R3 Corda [4] and Hyperledger Fabric [5] environments are written in object-oriented Java language [6], whereas the Ethereum-based Quorum environment [7] is written in Solidity contract-oriented language [8]. The author examined the three most popular permissioned blockchain frameworks, i.e., Hyperledger Fabric [9], R3 Corda [10], and Quorum [11]. Verification rules implementation of a smart contract is hardcoded in these blockchains. In R3 Corda, the validation is done in the _verify()_ method body of the smart contract's class. In Fabric, the implementation is a peculiar combination of flexibility and stiffness. The framework uses logical operators: _AND_, _OR_, and _NofMany_. However, rules and logical operators are embedded into a string. The complete logical expression is not available at the compile time. It should be underlined that such an approach forces the evaluation of a full verification ruleslist. In Solidity, rules are examined in functions of smart contracts as preconditions. That leads to redundancy in using the same rules in various functions. Therefore, the author sees the need to propose a more flexible approach to designing smart contracts with the ability to publicly define verification rules. Such an approach enables the reconfigurability of smart contracts in response to various transaction types. What is more, it fosters the reuse of verification rules among smart contracts. Prosumers use the energy they produce themselves from renewable sources. The surplus energy is fed into the power grid. In Poland, the current legal conditions do not allow for the free sale of energy among prosumers. The power grid operator collects the surplus of produced energy at significantly lower rates than those at which end consumers buy energy. Prosumer communities emerge in order to use the produced energy as fully as possible. Individual prosumers mutually benefit from the generated electricity. Additionally, it also becomes possible to exchange energy between various communities. For this purpose, IT systems are needed that enable the unquestionable billing of the produced, transferred, and used electricity. Such a system aims to measure the energy generated at the nodes of the grid, the energy transferred between nodes, and to minimize the feed-in of energy into the grid by managing its use within the same community and among various ones. A lot of current research work is devoted to such issues. A thorough analysis was conducted by [PERSON] et al. [12] on the usage of blockchain technology in modern energy sector areas: Energy Internet and Smart Grid 2.0. They examined the manner smart contracts can facilitate the transition to prosumer-oriented, distributed electricity grid management. The article uses the example of energy exchange between renewable energy prosumers to illustrate the reconfiguration of a smart contract. The contribution comprises the following elements:  
* 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.