| Literature DB >> 31647475 |
Matthew Johnson1,2, Michael Jones1,2, Mark Shervey1,2, Joel T Dudley1,2, Noah Zimmerman1,2.
Abstract
Decentralized apps (DApps) are computer programs that run on a distributed computing system, such as a blockchain network. Unlike the client-server architecture that powers most internet apps, DApps that are integrated with a blockchain network can execute app logic that is guaranteed to be transparent, verifiable, and immutable. This new paradigm has a number of unique properties that are attractive to the biomedical and health care communities. However, instructional resources are scarcely available for biomedical software developers to begin building DApps on a blockchain. Such apps require new ways of thinking about how to build, maintain, and deploy software. This tutorial serves as a complete working prototype of a DApp, motivated by a real use case in biomedical research requiring data privacy. We describe the architecture of a DApp, the implementation details of a smart contract, a sample iPhone operating system (iOS) DApp that interacts with the smart contract, and the development tools and libraries necessary to get started. The code necessary to recreate the app is publicly available. ©Matthew Johnson, Michael Jones, Mark Shervey, Joel T Dudley, Noah Zimmerman. Originally published in the Journal of Medical Internet Research (http://www.jmir.org), 23.10.2019.Entities:
Keywords: DApp; biomedical research; blockchain; decentralized application; geolocation; iOS; mobile health; privacy; smart contract; tutorial
Mesh:
Year: 2019 PMID: 31647475 PMCID: PMC6835476 DOI: 10.2196/13601
Source DB: PubMed Journal: J Med Internet Res ISSN: 1438-8871 Impact factor: 5.428
Smart contract properties: benefits and trade-offs.
| Property | Description | Benefits | Trade-offs |
| Transparent | The state of the app is public and inspectable. | App functionality can be audited and validated; Public nature of code incites collaboration. | Requires careful implementation to avoid exposure of sensitive data; Vulnerabilities can more easily be identified and exploited. |
| Autonomous | Can be designed and deployed such that it does not require any further interaction with the agent that deployed it. | No need for middleman or external arbiter. No external control or manipulation of app behavior. | No customer service: transactions cannot be reversed, and corrections cannot be made. |
| Immutable | The code defining the contract cannot be modified. | Guarantees that data policy will not change. | Cannot update smart contract with security fixes; requires new contract deployment. |
| Self-sufficient | Has the ability to coordinate and incentivize resources, in the form of tokens, to execute functions. | A deployed contract stays deployed on blockchain; does not require developer to pay for maintaining a server. | Lack of control over deployed malicious contracts; users of the smart contract pay transaction costs. |
Figure 1Decentralized application architecture and workflow—Smart contracts consist of self-executing code run on a blockchain protocol. Data flow directly between the smart contract and the clients: (1) Participant submits timestamped geolocation data; (2) Participant grants/revokes permission to share that data, to the smart contract; (3) A third party assigns geolocations of interest a matching category (ie, hospital, gym, pharmacy, or none) and deploy that mapping to the smart contract; (4) Participant can view the timestamp of each of their previously written geolocations and the category of that geolocation, if there exists a mapping between that geolocation and a category that was previously written to the smart contract by a third party; and (5) A third party can view timestamped data that the participant has chosen to share.
Features of traditional databases compared with Ethereum and the Oasis Devnet.
| Features | Traditional database | Ethereum (public) | Oasis Devnet |
| Data read access control | Yes | No, data is public | Yes, dependent on smart contract logic |
| Anonymity | Yes, if host is honest | Pseudo-anonymous | Pseudo-anonymous |
| Cost | Fixed | Variable | Free on developer network, will be variable in production mainnet |
| Data privacy | Yes, if host is honest | No, data is public | Yes, dependent on smart contract logic |
| Data mutability | Mutable, but can be immutable via role permissions | Immutable | Devnet gets reset, but the production mainnet will be immutable |
| Code can be updated | Yes | Yes | Not yet. Intercontract calls are planned |
| Publicly verifiable | No, the public cannot verify stored procedures | Yes, the public can verify smart contract codea | Yes, the public can verify smart contract codea |
| Widely accessible | Yes | Yes | Yes |
aFor both Ethereum and Oasis Devnet, the smart contract source code must be made public to verify that the contract is doing what is claimed.
Figure 2Simulator running the iPhone operating system app displaying the participant mode.
Figure 3Simulator running the iPhone operating system app displaying the third-party mode.
Decentralized app–related resources used in this tutorial.
| Tools and Libraries | Descriptions |
| MetaMask | Browser extension that serves as a Web3 wallet that can create and manage identities. It also injects the web3.js library into the browser to allow read and write requests to be made on blockchain networks, such as Ethereum or other networks by specifying a remote procedure call URL. |
| Oasis Contract Kit | Docker environment with a preconfigured set of tools for developing contracts on Oasis. |
| Oasis Devnet | Privacy-focused blockchain platform for developers to build and test confidential smart contracts; the platform used in this tutorial. |
| Remix | Web browser–based integrated development environment that allows developers to write, deploy, and run smart contracts written in Solidity. |
| Solidity | An object-oriented programming language for writing and implementing smart contracts on various blockchain platforms. |
| Truffle Framework | A development environment testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine; included in Contract Kit. |
| Web3swift | Open-source iOS library written in Swift. It provides web3.js functionality in Swift, native ABI parsing, and smart contract interactions. |
Figure 4Solidity method written to post the location of the participant. This method (postParticipantLocation), when called by the client, (1) checks to see if the sender is a new participant by checking to see if there exists a mapping for the sender’s address to an existing participant ID (addressToParticipant). (2) If one does not exist, the total number of participants is incremented (numberOfParticipants). (3) The senders address is then mapped to a participant ID that is equal to the count of participants.
Figure 5Simulator running the iPhone operating system app, displaying the user’s wallet information.