SouphiW / token-farm

DeFi Demo app that lets you stake some tokens and you'll be occasionally rewarded with an amount of $MATT tokens in proportion to what you staked!

Home Page:https://token-farm.on.fleek.co/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TokenFarm

Stake fake coins to yield fake rewards!

This is my capstone project from Patrick Collins' amazing freeCodeCamp + ChainLink's full course

Summary

With this app, you can interact with a Typescript React UI which allows you to:

  • stakeTokens: Add any approved token to the farming contract for yeild farming, collateral, or whatever you want to do.
  • unStakeTokens: Remove your tokens from the contract.
  • getUserTotalValue: Get the total value that users have supplied based on calculations from the Chainlink Price Feeds.
  • issueTokens: Issue a reward to the users staking on your platform!

How to yield your staking "reward"

The admin of the deployed contract can execute the issueTokens function to pay out a "reward" for staking your tokens within this app.

If you are playing with the deployed version of this app at link, I can send you your reward if you tweet at me!

Prerequisites

Please install or have installed the following:

Installation

This app uses Brownie. Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.

  1. Install Brownie, if you haven't already. Here is a simple way to install brownie. *NB: There is a breaking change within Python 3.10 and cytoolz that prevents a clean install of eth-brownie. I recommend downgrading to Python 3.9
pip install --user pipx
pipx ensurepath
# restart your terminal
pipx install eth-brownie

Or if you can't get pipx to work, via pip (it's recommended to use pipx)

pip install eth-brownie
  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 rinkeby or Kovan ETH and LINK. You can get LINK and ETH into your wallet by using the rinkeby faucets located here. If you're new to this, watch this video.

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

You can 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.

Useage

Scripts

brownie run scripts/deploy.py

This will deploy the contracts, depoly some mock Chainlink contracts for you to interact with.

brownie run scripts/deploy.py --network kovan

This will do the same thing... but on Kovan.

Front end

cd front_end
yarn
yarn start

and you'll be able to interact with the UI

Testing

brownie test

Linting

pip install black 
pip install autoflake
autoflake --in-place --remove-unused-variables -r .
black .

In App

The app allows for three mock tokens:

  • The custom minted MATT token, which you can pay yourself after deploying the ERC20 token contract
  • FAU token, which you can get from this faucet
  • WETH token, which you can get from this Kovan ETH faucet THEN by calling the deposit function from this contract

Resources

To get started with Brownie:

Any questions? Open an issue or tweet at me

License

This project is licensed under the MIT license.

About

DeFi Demo app that lets you stake some tokens and you'll be occasionally rewarded with an amount of $MATT tokens in proportion to what you staked!

https://token-farm.on.fleek.co/

License:MIT License


Languages

Language:TypeScript 44.5%Language:Solidity 28.5%Language:Python 22.9%Language:HTML 2.9%Language:CSS 1.2%