2 research outputs found

    Design Patterns for Ethereum Smart Contracts

    Get PDF
    The invention of Bitcoin in 2008 offered a solution for a digital currency that could be used without a trusted third-party settling disputes over transactions. Bitcoin relied on a technology known as the blockchain, which can be described as a distributed database that relies on a consensus mechanism (generally Proof Of Work is employed) to be resilient against tampering. Ethereum, launched in 2015, leveraged the blockchain technology to augment the initial proposal of Bitcoin, enabling computational statements to be executed as part of each block validation. The platform offers a Turing-complete runtime environment (the Ethereum Virtual Machine), which can run smart contracts - scripts that verify and enforce the execution of predefined legal contracts. The technical development of smart contracts present significant challenges that are not well modeled by the current body of knowledge and practices of software engineering. In fact, some of the characteristic of blockchain make the contract execution uncontrollable by the programmer and immutable after deployment. Also, the potential security risks are considerable, since there is a large incentive to exploit vulnerabilities in a smart contract for financial gain. Considering the concerns presented above, the establishment of well understood and welldefined design patterns for the development of smart contracts is of paramount importance. In the realm of software engineering, design patterns are defined as generic and reusable solutions to common problems in software design. In the context of this work, a survey of design patterns that target the Ethereum framework was performed, with an extensive analysis regarding the context in which they can be employed, as well as implementations, examples and consequences of their use. A total of 11 design patterns were analysed. The design patterns identified for the Ethereum framework focus on several concerns specific to this platform – most of these concerns revolve around safety, upgradeability, and the limitations inherent to the sandboxed approach of the Ethereum Virtual Machine. A Decentralized Application (dApp) was created to showcase the employment of several of the identified contracts, and to highlight the value they can provide. This dApp offers a framework for decentralized betting in a trustless environment, where neither the user needs to trust the owner nor vice-versa. The dApp implements several use cases that are reliant on the identified design patterns.A invenção da Bitcoin em 2018 disponibilizou uma solução para uma moeda digital que poderia ser usada sem a necessidade de envolver terceiros para a mediação de transações. A Bitcoin recorre a uma tecnologia conhecida como blockchain, que consiste numa base de dados distribuída, assente num mecanismo de consenso resistente a alterações não acordadas. Ethereum, lançada em 2015, utiliza a mesma tecnologia da blockchain para oferecer uma plataforma que se baseia na Bitcoin, mas que também permite a execução de instruções como parte do processo de validação de cada bloco. A plataforma permite correr contratos inteligentes (smart contracts) - scripts que verificam e garantem a correta execução de um contrato predefinido. O desenvolvimento técnico de contratos inteligentes apresenta desafios significativos que não são atualmente modelados pela área de engenharia de software. De facto, algumas das caraterísticas da blockchain fazem com que a execução de contratos não seja controlável pelo programador e também com que estes contratos sejam imutáveis após serem colocados na rede principal de Ethereum. Tendo em conta os pontos anteriores, é importante o estabelecimento de padrões de desenho (design patterns) bem definidos para serem usados em contratos inteligentes. No contexto deste trabalho, foi realizada uma análise dos padrões de desenho usados em Ethereum, tendo em conta o contexto em que são utilizados, as suas implementações e exemplos da sua utilização em contratos existentes. Um total de 11 padrões de desenho foram identificados e analisados. Uma Decentralized Application (dApp) foi desenvolvida para demonstrar o emprego dos padrões de desenho identificados. Esta dApp disponibiliza uma framework para se efetuar apostas de uma forma descentralizada, em que nem o utilizador necessita de confiar no dono do contrato, nem vice-versa
    corecore