Web 3.0 — Implementing a FUN-ctioning Use case

mrKishore
CryptoStars
Published in
9 min readJan 23, 2022

--

I had closed my previous blog with an hope to create my own digital asset (Token of Gratitude) so I can share it with you all. Here is the next step on that.

The previous blog was mostly theoretical and explained “Why” part of the hype and here in this blog I would like to talk about “What” from an Engineering perspective. It’s not necessary that you need to jump into this hype but there is no harm is learning a new Engineering skill. Fasten your seat belt. It’s time for some real work.

In this blog we will learn what it means to build a functioning Web 3.0 Application and some of the possible use cases. As I mentioned in my previous blog, the full bandwidth of possibilities on Web 3.0 is yet to be discovered and nobody is a real expert here. The common denominator on Web 3.0 understanding is that it is decentralized (we will see what it means) and involves the convergence of internet and the financial systems. Let’s start with this understanding and the use case where the peer-to-peer exchange of digital asset can be performed.

We are not going to use any of the existing cryptocurrency or a token but rather build our own. Yes, we are creating a new digital asset for the purpose of this use case. What would be the real value of this asset? Well, Zero! Any currency be it Fiat or Digital has value only if it is accepted in the network, in other words when there is a demand. If not the case, even the Fiat currency is meaningless. Remember the 2016 demonetization in India which made 500 and 1000 India Rupees Fiat Currency non-acceptable in the country.

Use case: Feedback-Klan

Imagine we do have Feedback-Klan a network where anyone can walk in and share their piece of work (art, blogs, books, etc.) and get honest feedback in return. Each valuable feedback is rewarded with a digital asset called “FDBK Token”. Anyone who wants to share their work to receive feedback must deposit/spend some “FDBK”. The FDBK token is interchangeable, meaning it can be swapped with other tokens or crypto currencies in the market. The ones with the high number of FDBK Token can not only participate in the network as contributors but as well on the governance. This is only an imaginative use case, but I guess you get my point. The critical step is not the creation of digital asset but the Network where this digital asset is valued. We are only doing this for fun, a learning experience, so we need not worry about the real value and the network demand.

Concepts:

We must understand the below concepts before we start architecting our solution for Feedback-Klan.

Blockchain vs Coin vs Token vs NFTs:

Blockchain is the underlying technology which acts as a peer-to-peer network and can be used as a distributed immutable ledger. Blockchain can be

· Public (anyone with an internet connect can connect and work with it) Ex: Ethereum, Solana, etc.

· Private (only the administrator can give access to a restricted set of people) Ex: Hyperledger Fabric.

· Hybrid (the combination of both public and private)

· Sidechain (that’s the secondary blockchain to main public chain and run transactions. The sidechain executes batch transactions and syncs with the main chain at the regular interval.

Coin is the basic cryptocurrency that is needed to perform any transaction on a particular network. For ex: The Ethereum block chain has its own crypto currency which is Ether. Solana has its own currency which is SOL. Every coin would have its own blockchain home.

Tokens don’t have their own blockchain, rather operates on the other existing networks like Ethereum and Solana. Tokens are classified by its standard like ERC-20 or ERC-721 on the Ethereum network. ERC-20 is basically the Fungible token, can be exchangeable as a currency on the network, interchangeable between other ERC-20 tokens on the network. ERC-721 is the Non-Fungible Token, which is unique in nature, often used to represent a Digital Art.

IPFS:

InterPlanetary File System (IPFS) is a hypermedia distribution protocol which enables the creation of completely distributed applications by connecting all computing devices with the same system of files. It aims to make the web faster, safer and more open. In IPFS, a distributed file system the files can be accessed via https://ipfs.io/<hash/path> or ipfs://URL schemes instead of https. In IPFS the content is addressed using the cryptographic hash as the path. Any change on the file or content would automatically generate a new hash making the old one invalid. We are going to use IPFS in this use case to store the Feedback data.

Architecting the Full-stack Solution:

For better understanding, we start with the Web 2.0 Architecture and compare how the implementation would typically look like and then transform the same to Web 3.0.

In Web 2.0, the application is hosted on a web server which serves the Front-end written in HTML, CSS, JS or any other JS frameworks where the Presentation logic is written and it will communicate with the Business logic often referred as Back-end written in Java, NodeJs, Python, etc. and the data is stored in a dedicated Databases like SQL Server, HANA, DynamoDB, etc.

In Web 3.0 the application front-end is not hosted anymore on the web server but rather on a IPFS distributed file system. In our case, we are going to use a service called Fleek. Fleek offers an option — IPFS Hosting which makes it easy to deploy the front-end files directly from Git on the IPFS protocol.

The Business logic is going to be represented as a Smart Contract written in Solidity running inside Ethereum Virtual Machine (EVM) that connects with Blockchain. To access and communicate with the Ethereum node we are going to use a service called Alchemy. Alchemy provides the supercharged blockchain API with all the functions of node, JSON-RPC, data correctness and scalability needed to work with a functioning blockchain application.

The data is also going to be stored in IPFS as JSON objects. Here we are going to use the service Pinanta. Pinanta provides the API which enables the JSON data content to be stored (pinned) and retrieved easily from IPFS.

Last but not least, in addition to the three layers that we are familiar from Web 2.0 world, we also need a digital wallet in Web 3.0 which holds the User’s asymmetric keys to authenticate and sign every transaction. Here we will use the crypto-wallet Metamask for the same.

So, this is how the final architecture for Feedback-Klan would look like.

This architecture and the technology stack will change quite a bit if you prefer to use Solana Blockchain instead of Ethereum. However, the concepts and learnings from this use case would come handy.

Another important thing one must consider is that every Transaction on the network is charged with transaction fees referred as Gas in Ethereum. In our use case to give feedback and be rewarded with the FDBK Token in return is considered as a transaction and we need to pay the gas fees. The gas fee is charged with the Ethereum’s native currency — Ether. Normally we would have to buy Ether via any of the crypto exchanges like Coinbase, Binance, etc. by spending actual fiat currencies in USD or EURO but as we are only learning for fun, we do have an alternative option to get a free Ether.

Ethereum offers multiples test networks in addition to the Mainnet. Mainnet is where the productive blockchain applications would be deployed and real Ether exists and there are other test networks like Ropsten, Kovan, Rinkeby, Goerli. Anyone can get a free Ether on test network via the faucets and utilize that for paying the gas fees. This Ether has no value outside the testnet and can’t be traded or exchanged. For our use case we are going to use the Ropsten Test Network and have our Smart Contract deployed on that.

It’s Demo time now ….

Are you excited to see how this whole architecture would materialize towards a functioning Application? Here is the rudimentary prototype that I built following the above arch.

Simple React front-end application deployed to IPFS via Fleek and can talk with the Ethereum Ropsten Testnet using the Alchemy API for executing the smart contract functions and as well connect (read/write) the data source (feedback-data) stored in IPFS via Pinata and display the feedback in a basic table view.

Here is our own digital asset “FDBK” token created and exists in the Ropsten Testnet — https://ropsten.etherscan.io/token/0x56026EdaeF8901ECd9E70D30169EC1749B98add1

As you can see above 100 million FDBK tokens has been created via the contract and it has 2 holders at this moment and 14 transactions has been performed. The tiniest portion of this token is going to be 18th decimal.

The only pre-requisite for using the above application or any of the Web 3.0 application is that you have crypto wallet like Metamask added to your browser and your account is set-up inside, so you have the needed crypto keys to sign the transaction. This can be done in just few seconds. After that you can enter your account address here in the faucet to get a free ether for the gas fee — https://faucet.ropsten.be/ . With that you are all set to try out the first Web 3.0 Application.

Just open the url — https://feedback-klan.on.fleek.co/, click Connect Wallet on top to connect your account (this is where the reward FDBK token will be transferred).

Enter your feedback now for Link — <any of my blog link> or particularly this one :-) https://mrkishore.medium.com/web-3-0-implementing-a-fun-ctioning-use-case-372fc5e6b91c , Rating (1–10), Feedback — <your honest feedback>

Click Submit Feedback, which would initiative the Metamask to sign the Transaction as below. Simply Confirm to sign and complete the transaction.

With that your feedback is stored in IPFS and You can see that appear in the Feedback List table on UI if you hit refresh. In a few seconds you would have successfully received the FDBK token on your account. You can verify that transaction on the Etherscan as shown above. You are now successfully included on the Holders list.

I am excited now to read each of your feedback on this blog and as well your experience on working with Web 3.0 Application built fully on blockchain compatible decentralized peer-to-peer network.

Some Key Takeaways:

· For End Users there is not a big behavioural change on the system except for the fact that now users are immediately authenticated to any application with their crypto wallet and the digital signature becomes their identity.

· There is not really a version management in the Smart Contract world as they are immutable. Any tiniest change to the contract could lead to creation of new contract address and needs full migration. If you have wondered why the reward is only the tiniest piece of Token in the above prototype, I was simply lazy to redo the whole process of the contract creation.

· The Hashes of the file or data content should be handled securely. Though we use Pinata for our use case, IPFS as such is a completely open peer-to-peer network so with the hash anyone can retrieve the data from the IPFS public gateway even without having access to Pinata. After all, IPFS wants to make the web more open.

· FDBK Token value is Zero as it exists only in the Ropsten Test Network and there is no demand for the same but if you have made it so far, I believe the knowledge that you gained and the newly added Technical skills are worth much more than any token can offer you.

If you are interested to learn the code base of the above Prototype, FDBK Token, full development set-up and step-by-step how-to walk through, Let me know in comments. I planned to do the same if there is enough interest.

--

--

Development Manager — SAP SE Germany , Leader, Aspiring “Organizational Architect”, Blogger, Artist, Author, My LinkedIn- https://www.linkedin.com/in/mrkishore