# Smart Contract Design Pattern for Processing Logically Coherent Transaction Types
## 2 Related Work  
The topic of smart contract development is a very fast-growing branch of software engineering. Despite the fact that significant progress has been made in the area of smart contract design, many challenges remain. The interview among professionals performed by Zou et al. [12] reveals the following obstacles that developers must face: lack of design methods of secure smart contracts, basic existing development tools, limitations of programming languages, performance constraints, and limited online resources. Vacca et al. [13] investigated tools developed for smart contracts. They highlight that the majority of the tools target the Ethereum framework, e.g., _SolMet_, _GasChecker_, and _SmartEmbed_. Only a few tools were written for Hyperledger Fabric, e.g., _Zeus_ and _Blockbench_. The tools gathered in the review help mainly detect security vulnerabilities in smart contracts written in Solidity language. Two of them have functionality close to software design issues: _SmartEmbed_ identifies code clones and _Gasper_ locates gas-costly programming anti-patterns. Gas waste in smart contract loops is considered by Li et al. [14] focusing on applying machine learning to detect the _Expensive Operation_ anti-pattern. However, none of them verifies the source code of smart contracts on compliance with design patterns. Two design patterns were introduced by Mandarino et al. [15]. The first is an architecture that reduces gas consumption in case of updating the source code of a smart contract. The second shows smart storing of data in the form of packing bits representing boolean values. The pattern for communication of on-chain smart contracts with off-chain services was proposed by Liu et al. [16]. They proposed a data carrier architecture that consists of three components: Mission Manager, Task Publisher, and Worker. Those components interact with smart contracts and off-chain data sources. Researchers also propose templates as an alternative way to unify smart contract design. For example, Jin et al. [17] developed the _Aroc_ tool, which generates a patch contract containing security rules based on the fixed template and deploys it to the blockchain. Templates are also the subject of other research. Furthermore, Gec et al. [18] propose a support system that recommends and provides smart contract source code templates suitable for a fog architecture, whereas Mao et al. [19] operate at a higher level of abstraction. They provide a set of specialized templates of basic functions for users to design smart contracts visually by the user interface. An interesting area where design patterns may appear is model-driven engineering, because generating smart contract source codes requires some template or design pattern. In this context, Bodorik et al. [20] show the transformation that generates the source code of smart contracts from the description of business models presented in Business Process Model and Notation (BPMN). Similarly, Shen et al. [21] also use BPMN to visualize the process to be understood by the stakeholders from various domains. They introduced a smart contract generator for developing multi-party interaction scenarios. In contrast, Jurgelaitis et al. [22] step lower at the level of system modeling and show the mechanism of generating smart contracts for the Solidity language from Unified Modeling Language (UML) state diagrams. Currently conducted research works concern the application of blockchain technology and smart contracts in various domains. Solutions for the medical sector are among the most intensively researched (Yang et al. [23]). Additionally, smart contracts are increasingly used in the energy sector, especially in distributed renewable energy systems (Honari et al. [24]). From its beginning, blockchain has been used in the financial sector (Wang et al. [25]). On the other hand, smart contracts are increasingly used in public services such as online voting systems (Saim et al. [26]).