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
Creating and connecting your wallet to ABOGIDA
Setting up your project
Smart-contract development
Using Hardhat for contract development
Deploying your contract on ABOGIDA
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:
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:
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:
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.
Adding your Front End
Adding your Front End
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