IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Tutorial 11: Buy and Sell DApp
Intended Learning Outcomes:
Copyright By PowCoder代写 加微信 powcoder
ILO1: Explain the concepts related to cryptocurrency, blockchain, and distributed ledger technologies. ILO3: Evaluate security issues related to cryptocurrency and blockchain.
Activity 1. Buy & Sell DApps [10 minutes]
In this tutorial, you will learn how to set up a dapp where users can buy and sell items.
Go to dTables and click on Create Table.
Name the dTable and create 4 columns as shown in the diagram. Then click Create dTable button.
Page 1 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
When the table is ready, go inside to create a record as in the diagram, then click Insert Record.
Page 2 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Go to Triggers, click Create Trigger
The customer is going to buy a product (digital card) from the owner (which is you), so the customer is using this Trigger to update our( itemForSales) dTable.
Because after the product is sold to the customer, the Price will reset to 0 ETH, no more stock.
Click the Next button to continue.
Page 3 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
We are going to create a .
Is the item for sale? If the price is greater than 0, then yes.
Click Next.
Page 4 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Configure Payment, Choose Yes.
The payment amount will be based on the Price column on our dTable¡¯s selected product. Payment will go to you, the product owner¡¯s address.
Click Next.
Page 5 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Type in the name and description of the new Trigger.
Click the Deploy button at the bottom (not showing in the diagram).
Page 6 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Open your new Trigger ItemsForSale_Buy to grant the permission.
Page 7 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Go to LiteUI to create a web user interface.
Click the + icon to add a new LiteUI.
Site Name: MarketPlace
Add Page: Items For Sales
Page 8 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Add UI Element: List -> dtables = itemsForSale
To connect the trigger, click … button.
Page 9 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Add the ItemsForSale_Buy trigger and name it as Buy.
Click Save button.
Page 10 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Save the MarketPlace LiteUI.
We are going to use LiteWallet. By using LiteWallet, we don¡¯t need metamask to do testing.
Page 11 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Click Create LiteWallet.
Name: Beta Tester for Marketplace Wallet Action: Navigate to LiteUI LiteUI: Marketplace
Number of Wallets: 3
Page 12 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Click Create button.
Page 13 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
You can click on 1 of the Access. You have some Eth on your wallet to buy products.
Page 14 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Select the product, click on the Action dropdown, then click Buy.
Click the Buy button to confirm. Now this product is now belonging to a new owner¡¯s address
Page 15 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Activity 2. Supply Chain DApps [30 minutes]
In this tutorial, you will learn how to create a Dapp that tracks coffee beans¡¯ origin on Ethereum.
Let¡¯s begin to add some dTables, first table is CoffeeOriginRoasters which stores a list of our roasters.
CoffeeOrignRoasters
Page 16 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
The second dTable is CoffeeOriginRoasts, which store a list of roasters roasts We will user pointer to relate to the CoffeeOriginRoasts dTable
CoffeeOrignRoasters
Page 17 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Add a third table, CoffeeOriginMods, which is to stores a list of moderators. They can add new roasters to the network. This is not a public network that everyone can join, it has to be invited by moderators.
Page 18 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Use Trigger to create business logic rules and API endpoints.
Insert Record to CoffeeOriginRoasters, moderator will be using it to input Roasters.
CoffeeOrignRoasters
Page 19 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Set a condition, to make sure only valid moderators can add roasters.
Page 20 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Page 21 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
We will create a second Trigger as shown in the diagram, which is to allow Roaster to add/insert a roast record, and it is linked with the CoffeeOriginRoasters table by the user¡¯s address.
Page 22 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Add a condition, the Roaster must be a member of the network
Page 23 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
We can deploy the Trigger contract.
Page 24 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Go back to dTable, CoffeeOriginMods, to add yourself as a Moderator, we didn¡¯t build a trigger to insert this record.
Click New Record
Page 25 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Time to build our LiteUI
Click + icon
Add Page: Roasters
Page 26 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Add UI Element, A List of dtable CoffeeOriginRoasters
Then add a New page, click Add Page +,
Page 27 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Add UI Element, a Form, where the trigger is CoffeeOrigin_AddRoaster
Page 28 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
We can do a Live test on the design view.
Page 29 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Next, Add 1 more Page +, name it Add Roast
Add UI Element, Form for CoffeeOrigin_AddRoast
Page 30 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Live test to submit a test record
Page 31 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Go back to Roasters Page,
Click on Details
Then add UI Element, a List of CoffeeOriginRoasts.
Page 32 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Click on … , then Configure
Page 33 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Rename the list to Roast, and configure as shown in the diagram.
Page 34 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Let Save our Dapp.
Here we go.
Let¡¯s test it, go to the Add Roaster page, go to MetaMask to add a new account. Then connect the account. Don¡¯t forget to send some Eth to the new account. It may take some time…
Page 35 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Use your new MetaMask account¡¯s address to fill the following Wallet textbox.
When you submit, make sure you are using your Atra¡¯s wallet address, which should be your original MetaMask account, not the new one.
Anyone can view Roasters, Only you can add a Roaster (based on address), and a verified Roaster (based on address) can then Add Roast.
Page 36 of 37
IS3101 Cryptocurrency & Blockchain (2021/22 Semester B)
Department of Information Systems, College of Business, City University of
Activity 4. Submit your work
Please submit your Buy and Sell DApp website URL, to Canvas “Tutorial 11 Submission”. Deadline: 1-week time.
Reference:
https://faucet.rinkeby.io/ https://console.atra.io/docs/tutorials/account-setup
Page 37 of 37
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com