Tools and their Usage in Development

Helloooo guys :wave:

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 :thinking: 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.

  • Remix
  • Metamask
  • Truffle
  • Ganache
  • Geth
  • Infura
  • Web3
  • OpenZeppelin
  • Faucets
  • Etherscan

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 :wink:


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.

Step 1
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’.

Remix
An online IDE for developing smart contracts. It has a built in compiler and you can develop, test and deploy contracts with it.
https://remix.ethereum.org/

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,

  1. Deploy using JavaScript VM
  2. Deploy using Injected Web3
  3. Deploy using a Web3 provider

Step 2
Before choosing a deployment option, we need to understand what’s the difference between those three. So lets get it cleared first.

  1. JavaScript VM is a virtual machine that comes in with Remix and it provides similar functionalities of a real blockchain.
  2. 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?

Web3
This is a library for javascript to interact with the blockchain.
https://web3js.readthedocs.io/en/v1.2.4/

Metamask
This is a wallet that can be used within a browser for interacting with blockchain applications, holding your tokens, cryptos and digital assets.
https://metamask.io/

  1. 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?

Ganache
This creates and runs a local blockchain on your system for you to develop, deploy, test and interact with applications.
https://www.trufflesuite.com/ganache

And that’s it. we can choose any of the three options to deploy our contract. But initially, it’s better to use JavaScript VM as we are only in the testing phase and we don’t wanna make any records or transactions to the real world network. Else, we can use Ganache to provide our own web3 provider. Using Injected web3 requires Metamask and it’s still possible to make Metamask point to our own local blockchain network through localhost. But why complicate things when there’s a better option.

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.

Step 3
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.

Web3
This is a library for javascript to interact with the blockchain.
https://web3js.readthedocs.io/en/v1.2.4/

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.

Step 4
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.

Truffle
This is a complete package for developing, testing, deploying and interacting with blockchain applications especially ethereum.
https://www.trufflesuite.com/truffle

OpenZeppelin
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.
https://openzeppelin.com/

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.

Step 5
We can use either Geth or Infura to interact with the real world network.

Geth
This is a software that can interact with the real world blockchain from your system.
https://geth.ethereum.org/

Infura
This provides an API endpoint for you to interact or deploy applications to the real world blockchain network.
https://infura.io/

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.

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.
https://faucet.rinkeby.io/

Step 6
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.

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.
https://etherscan.io/


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 :slightly_smiling_face:

5 Likes

Hi @manolingam,

Thanks for writing this tutorial :pray:
I remember those weeks of struggle connecting it all together. Appreciate everything which helps new developers not have that struggle.

I recommend using OpenZeppelin Starter Kits as a way to quickly get up and running.

Thorough testing is hugely important, the following is a great place to start: Test smart contracts like a rockstar

Plus the recently announced: OpenZeppelin Test Environment for Blazing Fast Contracts Testing.

Style matters and makes life easier for contributors, auditors and users: Create a style and stick to it

Finally the community shared their development environment and top three recommendations for a new developer in the space

2 Likes