In January 2022, I did a 30-day project on “Why Your Business Needs to Adapt to Blockchain”. This post is a part of it. To know what I covered, learned, and executed in the project, visit this page.
The goal of this exercise is simple. I’ll create a basic decentralized app or dApp. I’ll use the Hardhat framework to create the blockchain locally and I’ll use a Metamask wallet to connect to our local blockchain. I’ll deploy the final dApp on the Ropsten Testnet. I’ll be using Mohammad Nauman’s course on Udemy as a guiding force for this journey. But before I embark on it, let’s clarify some jargon first.
What is a decentralized app?
In a traditional application or app such as WhatsApp, Uber, or your browser app, the company creating the app holds the app in its own servers or cloud platforms. So, all your personal and financial data stays with the company. The server cost is one of the cost components of the company and the company’s revenues offset the costs. The company can choose to shut down the app any time they want.
A decentralized app does not run on a company’s server, but all the data is stored on the blockchain. A number of “volunteer” nodes spread across the world provide the computational power required to run the blockchain. As a user, you pay a “gas fee” for the computational power being used to process and handle the transactions.
Additional points to note about dApps:
- dApps can only be built on those networks that allow smart contracts. That means you can build a dApp on the Ethereum network but not on the Bitcoin network.
- The smart contracts on dApps are open source. So, unlike YouTube’s algorithm where you have no clue of how it suggests new videos, the workings of a dApp would be clear to any person interested.
- dApps cannot go offline as a regular app as they are run by hundreds of thousands of computers worldwide, and the possibility of shutting all down at the same time is close to zero.
The possibilities with a dApp are beyond imagination at the moment. Right now, we see applications in Decentralized Finance or DeFi (like AAVE), Decentralized Exchanges or Dexes (like Uniswap), game dApps (like Zed Run), gambling dApps, NFT marketplaces (like Rarible), etc.
What is a Metamask Wallet?
You need a wallet on a blockchain network to store and manage your cryptocurrencies. The tokens are secured by a private key and a public key pair. The public key is how you are identified by everyone else on the network (just like a username). The private key can only be used by you to sign a transaction on the network. The private key is secret. A wallet keeps track of your private keys and public keys and also allows you to create more pairs.
Metamask is a software cryptocurrency wallet that you can use while browsing the web and interacting with dApps. Metamask can store your private keys and can work on multiple networks such as the Ethereum network, Binance Smart Chain network, etc. So, you can send and receive Ethereum-based cryptocurrencies through your Metamask wallet. All you need is a Metamask extension on your browser.
What is Hardhat?
Hardhat is an Ethereum development environment. A development environment is a collection of tools and procedures that allow you to develop, test, and debug an app. So, you can develop, test, and debug an Ethereum-based dApp in Hardhat. It will help you learn how to interact with the blockchain on your local system before moving on to a globally distributed blockchain. Alternatives to Hardhat include Ganache, Truffle, and Remix IDE.
What is Ropsten Testnet?
One major drawback of the Ethereum network is that it has a low throughput. What that means is that the Ethereum network can only handle up to 30 transactions per second. As a result of the high usage of the network, it is expensive to make a transaction on the Ethereum network. So, if you created a dApp and wanted to test it on the Ethereum network, you would have to pay high gas fees. If there were any bugs on your dApp, you would have lost real Ethers.
The Ropsten Testnet solves this problem. It is an alternative network that allows you to test your dApp for free before deploying it on the Ethereum Mainnet (the blockchain where all the real-world dApps live and actual Ethereum is traded). You get fake Ethers as free gas to do the testing. Once tested on the Ropsten Testnet, a developer can move their dApp to the Ethereum Mainnet exactly the same way but by using actual Ethers.
Now that we are clear with the terminologies, let’s get down to business. In the next post, I will explain how I created a node, a Metamask wallet, and connected the node to the Metamask wallet. Read it here.