<<

CoinCrowder: An accountable Decentralized Application (DApp) with tamper-proof evidence of purchase and analyses

2021-03-06 Zuzsanna Dianovics & Nahid Ebrahimi Majd California State University San Marcos

This document is made available through ScholarWorks, the shared institutional repository of the California State University System. Visit https://scholarworks.calstate.edu/ for more openly available scholarship from the CSU.

Repository Citation Dianovics, Z. & Majd, N.E. (2021, March 3). CoinCrowder: An accountable blockchain decentralized application (DApp) with tamper-proof evidence of purchase and analyses [Conference session]. 2021 Computer Science Conference for CSU Undergraduates, Virtual. https://cscsu-conference.github.io/index.html CoinCrowder: An accountable Blockchain Decentralized Application (DApp) with tamper-proof evidence of purchase and analyses

Zsuzsanna Dianovics, Nahid Ebrahimi Majd

California State University San Marcos, United States

Abstract This gap of trustworthiness and transparency exists in the structure of crowdfunding applications currently used Crowdfunding is the practice of a project or in the web. This missing functionality of checks against venture by raising small amounts of money from a large purchases and tamper-proofing the evidences of purchases number of people, typically via the . One of the allows any product owner to spend the contributed funds main challenges in the current Crowdfunding platforms is as they wish with no accountability. accountability, whether the project owner spends the fund in an appropriate way to achieve the project objectives. One robust solution to fill this gap is utilizing The people who contribute to the project need a blockchain technology in the structure of the application. trustworthy platform that clearly elaborates how the raised money is spent. One great approach is to let these people The rest of this paper is organized as follows. Section 2 contribute to make decisions about spending the money. introduces the blockchain technology. Section 3 discusses The money could be spent only when a consensus is the related work. Section 4 elaborates the architecture of reached. Besides that, once a decision is made and a the DApp, which we named CoinCrowder. In Section 5 we financial transaction is confirmed, there should be no way analyze the computational complexity of implemented to change the decision or the transaction. In this project, DApp. Section 6 draws the conclusion and discusses the we used blockchain to design such platform. future directions of this research project. Inherent to the structure, blockchain tamper-proofs all data and financial transactions. 2. Blockchain Technology We used a crowdfunding blockchain decentralized application (DApp) and tested it on Rinkeby Ethereum Blockchain consists of a sequence of blocks, each network. We analyzed the computational complexity of the chained to the last block via the previous block’s hash. The DApp’s Ethereum smart contracts based on the amount of blockchain is stored on a decentralized peer-to-peer gas required to deploy the contracts and process the network. Each major node in this network, named a full transactions on Ethereum. node, stores a copy of the blockchain and also serves the other full nodes and several clients. The main benefits of this technology are as follows: 1. Introduction 1. Tamper-proof: Once a block of transactions is mined and added to the blockchain, any In 2019, the global crowdfunding market was valued at manipulation of that data will be immediately 13.9 billion U.S. dollars and was forecast to triple by 2026. revealed by the nodes. Crowdfunding platforms are great ways for getting the 2. Decentralized data management: The blockchain public to help fund a private project. However, since there network is independent from any centralized is no guarantee that the project owner will use the funds authority. It is managed by a peer to peer network. honourably, there is a gap in the application. Once the fund All the peers can control and monitor the data. is collected, the project owners may use it as they wish, 3. Transparent data: The transactions are publicly even if it is not to fulfil the project’s requirements. There available on the blockchain. is no way for the contributors to monitor the way the 4. Anonymized data: Transactions on the blockchain project owners spend the fund or whether it is required and are made between accounts, and the accounts are useful for the purpose of project. The project owners may anonymized. Although the transactions on the provide some evidence, e.g. a payment receipt, however blockchain are publicly available, the owners of the structure of current crowdfunding platforms even those transactions are anonymized. One single client may that accept cryptocurrencies like use thousands of different accounts for different (ICO) does not provide any embedded feature that proves transactions to better anonymize the accounts such evidences have not been tampered with. involved in their transactions. 3. Related work The application’s user interface contains several pages. The first page provides a list of campaigns. An Blockchain-based crowdfunding is an emerging authorized user can initiate a new campaign, access the economic phenomenon and a state-of-the-art strategy to details of an already existing campaign or contribute to a finance ventures. It has recently been investigated in campaign. When a user contributes to a campaign, several research projects. [1] proposed a blockchain-based MetaMask deploys and asks the user to confirm that the crowdfunding platform to raise funds for cyber-, given amount of Ethers is to be paid from the user’s insurance for cyber products. [2] compared and contrasted Ethereum Wallet. Once the user confirms, the application the success factors of blockchain-based vs conventional uses the coded Web3 API to upload the confirmed crowdfunding. A good understanding of these success transaction to the Ethereum blockchain. Since blockchain factors is crucial for companies to design their blockchain­ is transparent, anyone can observe that the transaction was based fundraising initiatives properly and facilitate added to the blockchain. However, due to anonymity, only potential to seek main signals and drivers of an authorized user, who is knowledgeable about the outstanding projects. For instance, some of the unique accounts affiliated with their project, can figure out that success factors of blockchain-based crowdfunding this transaction was made by a contributing account. An platforms referring to [3,4] are (1) accepting an account is a unique big number in HEX notation, created international currency like Bitcoin and Ether; (2) Open­ and managed by the user’s Wallet in MetaMask. source code; (3) social networks combined with the blockchain. In a different research study, [5] used social Another feature of this application is the people who media analytics, analysis of public discussions on social contribute to a campaign are confident that the contributed media, to track the evolution of knowledge about new funds are only spent with the consent of the majority of the technologies in finance among people. Their results contributors, known as Approvers. To be eligible to be an illustrated that during May 2017 to October 2018 when Approver, an individual must contribute at least a they studied the financial social interactions, the minimum value as set by the campaign Manager. When the discussions were dominated by blockchain technology, Manager needs to spend some amount of the collected cryptocurrency and Initial Coin Offering (ICO). funds, they will make a request containing the amount of required funds, the Seller’s account as a contingency of the Our main contribution in this paper is to examine a request, and the purpose of spending the funds. The trustworthy blockchain-based crowdfunding platform and Manager needs to receive a majority (at least 50%) consent analyse the computational complexity of deploying the to proceed in spending the requested funds. Once the designed smart contacts and uploading the transactions to Manager receives a majority of the Approvers’ consent, the Ethereum blockchain in terms of required gas. they may, at their leisure, make the purchase and send the funds to the designated Seller. Again, MetaMask deploys 4. The Architecture of CoinCrowder and asks the user to confirm that the given amount of Ethers is paid from the user’s Ethereum Wallet. The assumption is the payees accept Ethers for payments. Once We used a blockchain-based crowdfunding DApp [6], the user confirms, the application uses the coded Web3 consisting of the following items. API to upload the confirmed transaction to the blockchain. (1) A web-based GUI implemented in Next.js: the This method of spending contributed funds allows the campaign owners and contributors can visually contributors to participate in making decisions as to how interact with the program via the GUI. those funds are spent and to whom those funds are paid. (2) Smart contracts implemented in Solidity: the web­ Although the account numbers of the Manager, Approvers based GUI can interact with the blockchain, deploy and Sellers are visible publicly, anonymity is maintained smart contracts and upload transactions to the since the identity behind the accounts remains private. The blockchain via Web3 API. DApp implements the described mechanism of (3) Ethereum: we used Rinkeby, an Ethereum testnet contribution, requests for funds and consensus on spending (test network), as the blockchain to test the DApp. the funds in the designed smart contracts and deployed (4) MetaMask: the Ethereum users use MetaMask as a them into the blockchain. Then, we used Web3 API to Wallet to manage all their accounts and balances. invoke the functions of smart contracts to store the MetaMask is a browser extension. The DApp uses campaigns, Managers, contributors, requests, purchases, Web3 API to interact with MetaMask. etc. To run each of these functions, which are implemented in the smart contract, a new transaction is sent to the There are two groups of users who work with this system: Ethereum network and stored in the blockchain. Sending a (1) Managers, who initiate fundraising campaigns. transaction to the blockchain costs money, which is called (2) Contributors, who fund the campaigns. gas in the Ethereum terminology. Figure 1: CoinCrowder details of a Campaign

Figure 1 presents a screenshot of the application that At the bottom, there is a button to go to the next page elaborates the details of a campaign named Cuttingboard and visit the list of campaign’s requests. On the right, there Buddy Campaign. When an authorized user clicks on a are options to contribute to the campaign, create a new campaign’s name on the main page of CoinCrowder, they campaign or visit the list of all campaigns. will be navigated to this page. At the top-left, observe the page URL, where we visit campaign with account id A smart contract is a self-executing piece of code, starting with 0x7a64 in the campaigns folder. This consisting of functions and status (data), which is deployed campaign has been inserted to the blockchain with this at a specific address on the Ethereum blockchain. It is account id. At the top-right, observe the fox icon of the called a “contract” because the code that runs on Ethereum MetaMask Plug in. Anytime, an account should pay a fee, can control valuable currency like ETH and there is an it triggers the Wallet, and MetaMask deploys to get a agreement between the payer and payee directly written confirmation for the payment. into the codes of the smart contract. The code controls the execution, and transactions are trackable and irreversible. Figure 1 displays the details of a campaign with account This code permits trusted transactions to be carried out id starting with 0x7a64. The campaign’s Manager’s between different anonymous parties without a need for a account id starts with 0x74C9. A brief description of the central authority. Web3 provides APIs to interact with the campaign comes in the first block. The minimum smart contract’s code. contribution to become an approver is 100 wei, which comes in the second block. Wei refers to the smallest We used two smart contacts for this application: (1) denomination of ether (ETH), the currency used on the Campaign, to store and process the list of campaigns; (2) Ethereum network. For instance, 1 ether (ETH) is CampaignFactory, as a layer above that deploys new equivalent to 1018 wei. The third block demonstrates the Campaign smart contacts on the blockchain. The benefit of number of pending requests posted by the campaign using this higher layer is that CoinCrowder would not be Manager, which is 2 in this example. As long as the posted responsible to pay the fee to deploy a new Campaign smart requests are not finalized by the Manager, they remain in contract. Instead, the Campaign Manager will pay that fee. the pending status. The next block demonstrates the On the other hand, this higher layer is relatively simple; it number of approvers, the people who have contributed the contains only two functions to create and access contracts. predefined minimum amount and are eligible to vote on the Thus, while it significantly improves the efficiency, its Manager’s requests. The last block displays the impact on the computational complexity of the campaign’s current balance. implemented system is very low. The Campaign smart contract contains the campaign Table 1. Cost of important transactions in terms of Gas status and functions. The Campaign status contains the Transaction Cost (gas units) following information. Deploy Campaign contract 559,628 ContributeFund function 29,781 (1) The Manager’s account address. CreateRequest function 110,501 (2) An array of requests. Each request is a Struct. ApproveRequest function 66,221 (3) The minimum contribution to be an approver. FinalizeRequest function 40,713 (4) A mapping between approvers and their votes. FetchStatus 0,000 (5) A counter that counts the number of approvers. A summary of results is depicted in Table 1. This table Selecting a mapping structure instead of array for (4) presents the costs in terms of gas units. The cost of each significantly improves the efficiency in terms of both gas unit will be discussed in Figure 2. The results revealed computational complexity and required space on the that deploying an instance of Campaign contract is by far blockchain. A mapping stores data on demand while an the most expensive transaction, which requires 559,628 array stores the data for all items. With mapping, we only gas units. The reason is because the smart contract contains need a counter to keep track of the number of approvers, all the contract functionalities and processing an instance which is negligible. The Campaign contains the following of the contract includes processing all of its functions. functions. Deploying a contract contains a base cost of 32,00 gas plus 200 gas for each byte of code. The code of a smart contract (1) Constructor: called when the contract is deployed. is first complied to a bytecode, and then the bytecode will (2) ContributeFund function: receives the contributors be deployed on the blockchain. payments and collect them in the contract account. (3) CreateRequest: receives a purchase request from The amount of gas units required for the four main the manager and creates it. functions of the contract are given in Table 1. The gas (4) ApproveRequest fucntion: receives an approval for required for a “ContributeFund” transaction was the lowest a purchase request from a contributor and stores it. because its algorithm only transferred funds from one (5) FinalizeRequest function: receives a final decision account (the contributor) to another account (the contract). from the manager to finalize a purchase. This simple transferral of funds is considered low cost, as (6) FetchStatus function: returns the contract data. referenced in the Ethereum Yellow Paper [7]. On the other hand, the transaction for “CreateRequest” was rather high 5. Results and analyses because a struct is instantiated for a request and pushed onto an array of requests. These are higher cost We tested the DApp and smart contracts on Rinkeby and computations and are therefore more costly, which makes analysed their detailed computational complexities in the transaction fee much higher than the “ContributeFund” terms of gas. Gas is a unit of computational work that the transaction. “ApproveRequest” sets a Boolean in the array miner does to execute the transaction. As defined in the and increments a variable. “FinalizeRequest” makes a Ethereum Yellow Paper [7], a transaction’s gas limit is a comparison and transfers funds, which cost relatively scalar value equal to the maximum amount of gas that higher than “ContributeFund” transaction. The costs of should be used in executing this transaction. This is paid “ContributeFund” and “ApproveRequest” are paid by the up-front, before any computation is done and may not be contributors who call these transactions. However, the increased later. The most computationally efficient smart costs of “CreateRequest” and “FinalizeRequest” are paid contract is the one that pays minimum gas to execute. A by the campaign Manager. smart contact needs to pay gas for 2 types of transactions: In addition to gas limit, which is the maximum number (1) To get deployed on the blockchain. of gas units required to execute a transaction and upload it (2) To change its status by executing its functions and to the blockchain, each transaction gets another metric store its new status on the blockchain. Notice that named gas price. The gas price is the fee paid for each gas fetching the current status of the smart contract unit in terms of Gwei, where 1 Gwei is equivalent to 10-9 from blockchain is free and needs no gas. ETH. For instance, if a campaign Manager offers 13 Gwei for gas price, 13*559,628 Gwei is required to deploy this We analyzed the gas required to execute these two types new campaign on the blockchain. Once a transaction is sent of transactions for the Campaign smart contract, which is to Ethereum, it should be mined by the miners to be significantly more complex than the other smart contact in appended to the blockchain. The gas price is an incentive this DApp. It is important to mention the cost to fetch the to the blockchain miners. A miner would rather process a contract status is zero gas since reading data from transaction with a higher gas price earlier than others. blockchain is free. However, in the current Ethereum environment, We used Web3 as the provider or communicator although offering high gas price is an incentive for miners between the implemented DApp, the smart contracts, and to speed up the transaction’s mining process, low gas price the blockchain. The smart contracts are implemented in will not hinder the transaction being eventually mined even Solidity and tested using Mocha and Ganache testing tools. if it takes longer than the predefined average 14 seconds. We used Next.js technology to for the front-end user According to Etherscan’s “Ethereum Average Block Time interface and deployed the smart contracts on Rinkeby, one Chart,” the average time to mine a block has remained of the testing networks of Ethereum. between 13.00 and 13.99 seconds in 2020. Our analyses revealed that deploying a contract is the most computationally expensive transaction in the overall process of running a DApp. The deployment of the contract is paid by the campaign owner. Those transaction fees that contributors are responsible for paying, such as the smart contract functions, are nominal in comparison, making DApps a viable option monetarily for public use.

In future, we plan to integrate this DApp with InterPlanetary File System (IPFS) to share files, particularly receipt of payments, between the campaign owner and the contributors.

Figure 2: Confirmation time vs gas price on Nov 16, 2020 Acknowledgments

In another aspect, we discuss the gas price value. in We acknowledge the support we received from Figure 2, we summarized the average time to confirm Undergraduate Summer Scholar Program at California transactions for different gas prices offered for 1000 blocks State University San Marcos. We also acknowledge San on a sample day, Nov 16, 2020 at around 04:00:00 UTC. Diego ESET, who sponsored this project. We referred to the Ethereum gas tracker data to plot this chart. The confirmation time of a transaction contains the References time required to collect a set of transactions including this particular transaction to form a block, mine the block, [1] I. Vakilinia, S. Badsha and S. Sengupta, “Crowdfunding the append it to the blockchain, and confirm it. Over the time Insurance of a Cyber-Product Using Blockchain,” IEEE this data was collected, the average gas price paid by the UEMCON, 2018. transactions owners was 22 Gwei, and the average time to [2] F. Hartmann, G. Grottolo, X. Wang and M. I. Lunesu, confirm a transaction was 133 seconds. However, the gas “Alternative Fundraising: Success Factors for Blockchain­ price and average confirmation time alters over time, and Based vs. Conventional Crowdfunding,” IEEE IWBOSE, the transactions’ owners could select the minimum gas 2019. price according to their priorities at each time. [3] G. Fenu, L. Marchesi, M. Marchesi, and R. Tonelli, “The ICO phenomenon and its relationships with Ethereum smart contract environment,” IEEE IWBOSE, 2018. 6. Conclusions and Future Plans [4] F. Hartmann, X. Wang, and M. I. Lunesu, “A hierarchical structure model of success factors for (blockchain-based) In this research project, we used a trustworthy crowdfunding,” 2018. Decentralized Application (DApp) for crowdfunding, and [5] C. I. Bogusz, C. Laurell and C. Sandstrom, “Tracking the the smart contracts required to make interactions between Digital Evolution of Entrepreneurial Finance: The Interplay the DApp and Ethereum blockchain. The motivation is the Between Crowdfunding, Blockchain Technologies, accountability provided by the tamper-proof feature of Cryptocurrencies, and Initial Coin Offerings,” IEEE Transactions on Engineering Management, 2020. blockchain. Then, we analysed the efficiency of the [6] S. Grider, “Ethereum and Solidity: The Complete Developer's implemented smart contracts in terms of units of gas Guide,” 2019. required to process and upload the transaction to the [7] G. Wood, “Ethereum: A secure decentralised generalised blockchain. We also presented an analysis on gas price. transaction ledger,” 2014. Gas is spent in ETH, the monetary system of Ethereum blockchain, and is transferred via a Wallet, embedded in Address for correspondences: MetaMask, which holds all the accounts and public/private key pairs of an individual. This wallet is embedded in a Zsuzsanna Dianovics, Nahid Ebrahimi Majd browser and attaches to any and can be used by 333 S Twin Oaks Valley Rd, San Marcos, CA 92096. [email protected], [email protected] any user who has an Ethereum account.