In this post, I wanna connect the various tools that are used in development process for building any Ethereum application especially Dapps. This is because when I started learning blockchain development, there were so many terminologies like Ganache, Truffle, Remix, Infura, Geth, etc. And I was confused on how to connect those together? how do they work? and how to use those for development?. So after weeks of googling, developing, debugging, etc, now am pretty comfortable with developing and deploying a Dapp.
So this post will let you overcome those weeks of my struggle and get you quickly understand what those are and their relationship. Lets dive in!
Note that I will not be coding along. Instead I would be explaining what the tools are and when to use it.
The following are the tools that I know so far. Maybe this list will increase when I get to know more. But these are good enough to get started.
Before getting to define each of those, let us proceed with a development driven approach so that you can both know what they are and how to use them
THE DEVELOPMENT PROCESS
To get started, let's say you have an idea of creating a dapp that simply registers a user's lucky number.
So to begin with, the first step would be to write a smart contract for our dapp. And we don't need to fire up our code editor to this. Initially its good to write smart contracts using an online IDE called 'Remix'.
An online IDE for developing smart contracts. It has a built in compiler and you can develop, test and deploy contracts with it.
Okay, consider we have written a contract and the remix compiler is fine with it. Now, how to test it?
We deploy to a network and then interact with it. And Remix provides us with three options,
- Deploy using Injected Web3
- Deploy using a Web3 provider
Before choosing a deployment option, we need to understand what's the difference between those three. So lets get it cleared first.
- Injected Web3 is a blockchain provider that comes in with a browser. And Metamask provides an Web3 object to the browser to interact with the blockchain.
But what is Web3 and Metamask?
This is a wallet that can be used within a browser for interacting with blockchain applications, holding your tokens, cryptos and digital assets.
- Web3 provider option is used if we have our own local blockchain setup running and we wanna connect to it. And a local blockchain can be used with the help of Ganache.
What is Ganache?
This creates and runs a local blockchain on your system for you to develop, deploy, test and interact with applications.
Next, we need to create a frontend for users to interact with our smart contract. And Remix can't help with that. We would need an IDE like VSCode.
For our frontend, we can keep it as simple as a simple HTML page with CSS and JS or we can use a frontend framework like React. But since ours is a very tiny dapp, we can keep it simple.
Consider our frontend code is ready. Now, how to interact with the blockchain from our frontend?
This is where Web3 is used. It acts as an interface between our frontend and blockchain.
Once our frontend is done and is connected to blockchain using web3, we need to test our smart contracts before deploying to a network as smart contracts are immutable.
Since there's a lot to be done with developing dapps like using web3, testing, migrating, etc, why not use a framework or tool for developing a complete blockchain application. And this is where Truffle and OpenZeppelin can be used. Both of them provide a wide range of functionalities like contract migration, testing, deployment, etc.
This is a complete package for developing, testing, deploying and interacting with blockchain applications especially ethereum.
This is similar to truffle which provides a wide range of tools from basic to advanced that helps you get started with developing blockchain applications on ethereum.
We can use either of them for developing, testing, connecting, interacting with ethereum blockchain. Truffle and OpenZeppelin provides an easy to use interface and functionalities for quick development process. Infact, OpenZeppelin provides even more advanced functionalities like Gas Station Network, Smart contract security, Smart contract standards, Smart contract upgradability etc.
Once testing is done, we need to deploy the contracts to a network. And to deploy, we need to interact with the blockchain.
We can use either Geth or Infura to interact with the real world network.
This is a software that can interact with the real world blockchain from your system.
This provides an API endpoint for you to interact or deploy applications to the real world blockchain network.
Geth is little complex to use while Infura is as simple as fetching data from an API. Infura provides an endpoint for us which we can configure in our Truffle or OpenZeppelin networks file and can easily deploy with a simple command.
But deploying contracts costs gas which in turn costs Ether. So we need to own some ether in our wallet from which we will be deploying the contracts. If we are going to deploy to some test networks like Rinkeby, we can get some test ether from Faucets. Else, we would need real ether to deploy on the main network which cannot be got from faucets.
These are used to get some test ether for you to deploy and interact with your applications over any test network. An example would be the Rinkeby faucet.
Once our contracts are deployed, Truffle or OpenZeppelin console provides us with the deployed contract's address in the network which we can look up using Etherscan.
This is the one place that you would require to see all the available dapps, tokens, transactions, etc on the ethereum network. In other words, its a complete database for all the happenings in ethereum network.
And that's it! Those were the steps and tools that are usually followed while developing any ethereum application (atleast I followed it) & hope that was helpful. If you have any other tools that is great to mention, let me know