Back to videos

How to build a Dapp - Interacting with a smart contract using React and Ethers / useDApp

Overview

In the first tutorial, we created a simple smart contract for our tower and deployed it to the Rinkeby testnet blockchain. Now, in this second part, we’ll take the next step: building a frontend with React and learning how to interact with the deployed smart contract using the Ethers library and the useDApp framework.

By the end of this tutorial, you’ll have a functional React app that can connect to MetaMask, send transactions to the blockchain, and retrieve event logs from your contract.

Why Learn Smart Contract Interaction?

Building a smart contract is just the first step in Web3 development. To create a fully functional decentralized application, you need a frontend that allows users to interact with the blockchain. This tutorial will help you understand:

  • How to check if a wallet is installed and connect it to your website.

  • How to verify if the wallet is on the correct blockchain network.

  • How to create transactions and interact with the smart contract.

  • How to retrieve event logs from your contract.

Insights and Skills

Throughout this tutorial, you’ll gain hands-on experience with:

  • Connecting a React application to MetaMask.

  • Using Ethers.js to interact with the Ethereum blockchain.

  • Using useDApp to simplify blockchain interactions in React.

  • Sending transactions to create new floors in the tower.

  • Retrieving and displaying event logs from the smart contract.

Tech Stack

Code link

Resources

  • [To get further :

The excellent CryptoZombies courses](https://cryptozombies.io/en/course)

#solidity #web3 #dapps

Need help with this tutorial? Join our Discord community!