Skip to content

A dapp application for staking token in order to mine farm token

Notifications You must be signed in to change notification settings

codebestia/TokenFarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Token Farm

A Decentralized application built with solidity for the smart contracts and react for the frontend. it is an application where users stake any amount of the tokens they have (dai or weth) token and they are given farm token (the native app token) in intervals based on the value of the amount of the token staked. Users can stake both dai and weth. The smart contract of this application is deployed to the goerli blockchain.

Prerequisites

Please install or have installed the below program:

Installation

  1. Install Brownie, if you haven't already. Here is a simple way to install brownie.
pip install eth-brownie

Or, if that doesn't work, via pipx

pip install --user pipx
pipx ensurepath
# restart your terminal
pipx install eth-brownie
  1. Clone this repo
# open your terminal
git clone https://github.com/codebestia/TokenFarm.git
cd tokenfarm
cd contract
  1. Install ganache-cli
npm install -g ganache-cli

If you want to be able to deploy to testnets, do the following.

  1. Set your environment variables

Set your WEB3_INFURA_PROJECT_ID, and PRIVATE_KEY environment variables.

You can get a WEB3_INFURA_PROJECT_ID by getting a free trial of Infura. At the moment, it does need to be infura with brownie. You can find your PRIVATE_KEY from your ethereum wallet like metamask.

You'll also need testnet Goerli ETH and FAU or WETH. You can get ETH into your wallet by using the Goerli faucets located here. You can get FAU into your wallet by using the FAU faucets located here.

You'll also want an Etherscan API Key to verify your smart contracts.

Create a .env file in the contract directory and add your environment variables to the .env file:

export WEB3_INFURA_PROJECT_ID=<PROJECT_ID>
export PRIVATE_KEY=<PRIVATE_KEY>
export ETHERSCAN_TOKEN=<YOUR_TOKEN>

DO NOT SEND YOUR KEYS TO GITHUB If you do that, people can steal all your funds. Ideally use an account with no real money in it.

Then, make sure your brownie-config.yaml has:

dotenv: .env
  1. Install the React frontend dependencies
# open a terminal in tokenfarm directory
cd tokenfarm
cd frontend
cd tokenfarm
npm install

Usage/Examples

  1. In the contract directory, compile the smart contract code
brownie compile
  1. Deploy and run scripts for initial setup
brownie run scripts/deploy.py --network goerli
brownie run scripts/add_accepted_tokens.py --network goerli
  1. Navigate to the frontend/tokenfarm directory and start the frontend
cd frontend
cd tokenfarm
npm run dev

You can now interact with the dapp application. try staking and unstaking your tokens.

To Issue tokens to Staker run

brownie run scripts/issue_tokens.py --network goerli

Check the balance of the staker farm token, it should have increased.

Note: I am using fau token as my dai token for this project, since it is easy to acquire the faucet.

Screenshots

Start Image

Second Image

Third Image

About

A dapp application for staking token in order to mine farm token

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published