Author: Yongxin Xu

In the previous three blogs, I introduced the blockchain development tools that we can use, the Forge Framework by ArcBlock, and the four questions to be considered before doing a blockchain project. In addition, I shared the process of working on my vending machine DApp from coming up with an idea, to modeling, and actually deploying a smart contract.

Today, under my four weeks of study, hard work, and everyone's attention and encouragement, my vending machine DApp has finally come true! In this post, I will show you my DApp. In addition, since it will be the last post of this series, I want to share with you my experience in developing my own blockchain project this month.

Let’s first do a quick review of my DApp model with everyone. My dapp is a trustworthy ledge of vending machines and is divided into three parts (the creation of bills, the recording of bills, and the presentation of bills). The second part, the recording of bills, is on-chain, and it is achieved by deploying a self-define smart contract as mentioned in my last post. The creation of bills and the presentation of bills are done by off-chain traditional methods. These two parts are what I have been doing in the last two weeks.

dapp model

The off-chain part of my vending machine DApp is composed of three parts, and their programming languages are python.

  • Billing simulator. When it is first used, the simulator will create a certain amount of wallets for our vending machines and related parties. Then, it randomly generates all the data in a bill, including the item information (item’s name, price, and purchase time), as well as the merchant information (the relevant party wallet address). Later, it put those data to the chain by sending an aggregate transaction which we deployed last time. The simulator completes the two parts of my DApp, the creation of bills and the recording of bills.

simulator

  • Database. Built by sqlite3, the database synchronizes all transaction data on the chain, including the hash value returned from the chain after a transaction is successfully sent. Like everyone's fingerprint, the hash of each transaction is unique. We can easily verify each transaction on the chain through its hash. This database is for the convenience of building a client platform, that is the third part of my DApp --the presentation of bill. The structure of stored data by blockchain efficiently ensures the authenticity and verifiability of the data in all nodes, but it is not easy to perform efficient and complex queries. So for a better user experience, for displaying data in a more convenient way, we still need to retrieve data from a “middleman” --database.

database

  • Client platform. This platform is developed by an existing web application framework, Dash. It has two main functions, one is to view the bill. You can view the ledger of any relevant party, including information of the account, a list of billing information, and total sales turnover and corresponding profit sharing. You can also pick billing information for a certain time period by selecting a date. The second part is a visualization of data. For example, the current market share of all vending machine operators in the vending machine market, their vending machine distribution maps, as well as the sales of each vending machine, and the corresponding best selling items. This information is updated in real time with the data on the chain and can be used for market data analysis.

webapp2 webapp1

The three parts above, together with the blockchain, form the complete vending machine DApp.

dapp structure

At the moment, you may have a question: “since your client platform is still implemented by retrieving data from the database, and you said the traditional database has a trust problem, then, how does your client platform solve this trust problem?”

In fact, I was a little hesitant when I decided to use the database. But then I suddenly realized I have ignored a key advantage of my DApp --when clients doubt the authenticity of data, they can go to the chain to verify it!

That is why I provided the hash of each transaction in the client's billing information list, and provided a link to the Forge web to facilitate the client to query the record of a transaction on the chain at any time. Therefore, although the off-chain structure of my DApp is similar to our existing system, because of the blockchain to record the data, and because of its immutability and verifiability, my DApp has inherently has a high level of trust, which makes it different from the existing system. In addition, from another perspective, this also shows that we can easily and conveniently combine blockchain technology with our existing systems and empower our current applications by using Forge Framework.

forge web

After developing my first dapp, I have some experiences to share with you::

First of all, I am really excited that I successfully implemented my first blockchain project. In fact, I did not learn anything about computer science until my freshman year. I did not have rich experiences in programming applications. Therefore, when the DApp idea came to my mind, and especially it is all about blockchain such a “new” thing that is not well-known by the public, I was a little doubtful of my ability. So when I saw my progress week by week, and saw my DApp gradually came to life, I felt very excited and satisfied.

Second, through these four weeks of development, I deeply realized that the blockchain is not really a mysterious technology. At the same time, it is really simple to build a DApp by using the Forge Framework provided by AcrBlock. Because Forge Framework solves the underlying complicated blockchain technology, when we want to develop a DApp, we don't need to thoroughly understand every detail behind the blockchain technology. We just need to understand that what problems in life can be solved by blockchain and how to use ArcBlock’s development tools, then we may start to build a DApp. In addition, with the help of Forge SDK, we can easily complete all the transactions on the chain, as well as the interaction between on-chain and off-chain, by simply writing a few lines of code. Now, after developing the vending machine dapp, I can also be proud to say that I am a DApp developer!

Third, I have actually felt that the era of blockchain 3.0 has arrived. We can finally, and easily, apply blockchain to every aspect of life. Now there is a vending machine blockchain project that solves the trust problem in business cooperation. I believe we will build more and more blockchain applications to solve all kinds of problems and change our lives very soon.

Let us look forward to this near future.