Skip to content

ndthinh8796/staking-example

Repository files navigation

Staking Example DApp

A simple staking contract connected to a Nextjs Front end.

Features

  • User can connect Metamask wallet to stake and withdraw
  • Owner can issue reward to staked users
  • Issue and reward your own token
  • Supported tokens: Wone, Weth, Dai

Tech

  • Hardhat - Ethereum development environment
  • NextJS - The React Framework for Production!
  • TailwindCSS - A utility-first CSS framework

Configuration

These following steps is for deploying and using contract on Harmony testnet. You can change to any network you like by changing the config.

Step 1. Set up environment variables

Copy the .env.example file in this directory to .env (which will be ignored by Git):

cp .env.example .env

Then set each variable on .env.local:

Your .env file should look like this:

PRIVATE_KEY=...

Step 2. Install dependencies

npm install

# or

yarn

Step 3. Deploy your own contract

npx hardhat run scripts/deployToHarmony.ts --network harmony_testnet

# or

hh run scripts/deployToHarmony.ts --network harmony_testnet

Your contract should be deployed to Harmony Testnet. The staking contract and token contract address should be printed on terminal.

NDTToken deployed to: ...
TokenFarm deployed to: ...

You can check the address on https://explorer.pops.one/

Step 4. Copy contract abi to front end

cp -R artifacts front_end/src/lib/

Step 4. Run Next.js in development mode

cd front_end && npm install && npm run dev

# or

cd front_end && yarn && yarn dev

Your DApp should be up and running on http://localhost:3000!

About

web3 staking platform example

Resources

Stars

Watchers

Forks