Building a Full Stack Dapp

In the following tutorial, we will go through a step-by-step guide on how to create a full-stack Hello World App that interacts with ABOGIDA. This tutorial is designed for either new developers interested in Dapp development or existing devs interested in migrating to ABOGIDA development.

Throughout the tutorial, feel free to reference other pages in our documentation for information with greater depth - however this tutorial will give you a basic understanding of how to get up and running.

Guideline Overview

  1. Creating and connecting your wallet to ABOGIDA

  2. Setting up your project

  3. Smart-contract development

  4. Using Hardhat for contract development

  5. Deploying your contract on ABOGIDA

  6. Integrating your smart contract with your project's front-end

Wallet

  • Select one of the wallets to store ABO gas token (xABO).

  • Fund your wallet with xABO using one of the faucets.

  • To interact with dApps, we recommend to setup and configure MetaMask.

Setting up your project

Tech Stack:

  • Waffle, a library for writing and testing smart contracts.

  • Hardhat, a development environment used for smart contract compiling, deploying, testing and debugging.

  • Ethers.js, a library for interacting with Ethereum Virtual Machine (EVM) chains.

First let's initialize your project:

Now let's run Hardhat to create a project:

This is what you should see:

Select the ▸ Create a basic sample project option.

Make sure to select yes for this option:

We will be using Waffle and Ethers.js later on.

Run the below just in case they weren't automatically added:

After the following, we can check if Hardhat is working smoothly with:

You should see:

Moving forward, let's delete sample-test.js under test, sample-script.js under scripts, and lastly Greeter.sol under contracts.

Make sure not to delete folders, we will be working with them still.

Writing a contract

First create the file WavePortal.sol under the contracts folder.

Then input the code below:

Deploying your Contract

To deploy your contract to ABOGIDA, let's update your config file at hardhat.config.js. For a complete configuration check hardhat config guide.

Proper management of your private key is extremely important. To ensure its safety, we have added it to an environment variable file, also known as a .env file. It is crucial that you do not upload this file to GitHub or include it in source control. Even if you delete it later, assume that the file will continue to exist after being committed and that it is compromised. If you plan to commit, add .env to your .gitignore or store it securely in an environment variable.

Let's install dotenv, to safe-keep your private key:

Note

Make sure to refresh your console/terminal afterward, to make sure you have dotenv in your current environment.

Create a .env file in your root directory

In this file, add your private key like:

Next, create your deploy.js file under the scripts folder:

Now before you deploy, make sure you have funds in your wallet! Visit the funds page, if you don't have funds.

Deploy to GIDA-Chain with the following command:

npx hardhat run scripts/deploy.js --network GIDA

Your output should look like:

The WavePortal address variable, is your contract address.

You can verify the deployment on https://gidascan.io/, by putting your contract address in.

Adding your Front End

To get your front end up and running quickly, visit this Replit link and fork it by clicking the Use Template Button on the right side of the page.

Navigate to the App.jsx file in Replit and follow the directions below:

To connect your contract with your front end, replace the contract address variable below with the address of the contract you received after deployment.

Lastly, in the Replit utils folder, we need to replace the WavePortals.json file with the generated json from when you deployed your contract.

In the repository you worked on your smart contracts, navigate to artifacts/contracts/WavePortal.sol/WavePortal.json, and copy that whole file into the replit file talked about above.

The file should look something like this:

Interacting with Contract

Congrats! You have created a full-stack DApp on GIDA.

Last updated