Design patterns for Ethereum smart contracts - Moura, Tiago Augusto Pinto (2020)
The Ethereum platform has become very popular in recent years in smart contract development, an area in which several programming languages are applied. Solidity, nevertheless is the most popular and widely used. On top of blockchain technology, Ethereum and its smart contracts have enabled developers worldwide to create innovative solutions in various areas such as finance, healthcare, insurance, internet of things, supply chain and others. These solutions are referred to as Decentralized Applications (dapps) and use the distributed nature of blockchain technology to solve problems in a disruptive manner, casting out intermediaries and automating processes. The fact that blockchain transactions triggered by smart contract execution are unchangeable also provides dapps users with a lot of confidence when compared to traditional centralized apps, because dapps’ data becomes tamper-proof. In the context of this work, it was necessary to analyze and look for software design patterns in order to help making the development of Solidity smart contracts simpler and safer, thus giving confidence both to users and developers of dapps built with Ethereum. In an initial phase, a literature review was made and 62 design patterns were found. From this set, 30 design patterns were selected for the practical component of this work. In this stage, 318 smart contracts were analyzed and the 30 previously selected patterns were confirmed. Additionally, four more patterns which had not been identified in the literature review stage were found. The 30 design patterns were divided into four categories: authorization, control, maintenance and security. Efficiency across all these categories was evaluated in terms of gas consumption and security vulnerabilities. Once the research was completed, it became possible to create a set of recommendations for Solidity developers.