Skip to content

Blockchain Staking ERC20 Token to Earn Liquidity Pool Reward Token as Tickets to Win NFT Lucky Draw on Testnets

Notifications You must be signed in to change notification settings

CZ4153-P02T4/khyber-farm

Repository files navigation

Khyber Farm

image

This repository provides a DAI staking mechanism; whereby, the user receives KhyberToken as a reward for staking DAI in the contract. Furthermore, the user can purchase a KHRYSTAL NFT through the NFT factory named Khyber Crystal. The KhyberTokens are sent to a lottery pool inside the Lottery contract. Finally, each NFT includes a tokenId which acts as a lottery ticket. The lottery feature uses Chainlink's VRF to provide a verifiably random number. The winner receives the contents of the lottery pool.

P02T4.mp4

Prerequisites

NodeJS and NPM >= 7.5.0

Installation

In directory root:

npm i

Testing

npx hardhat test

Deployment

Prerequisites

This dApp accepts DAI as its staking token; therefore, you'll need to acquire Kovan DAI if you deploy to Kovan (as it's preconfigured). To attain kDAI, you'll need to lock kETH in a Maker vault in exchange for kDAI.

The Hardhat configuration file and scripts have been set up to deploy on the Kovan testnet. Use the .env_sample as a template for the requisite API_KEY and PRIVATE_KEY. Infura and Alchemy offer free API access to testnets and mainnet. Once you have an API endpoint and your private key from MetaMask, create a dotenv file within the KhyberFarm root:

touch .env

Populate the .env with your API_KEY and PRIVATE_KEY.
*If you're posting on GitHub, DO NOT FORGET to .gitignore the dotenv(.env) file!

Uncomment out the Kovan network details in hardhat.config.ts:

networks: {
    kovan: {
        gas: "auto",
        gasPrice: "auto",
        url: process.env.API_KEY_KOVAN,
        accounts: [`0x${process.env.PRIVATE_KEY}`]
    },
    rinkeby: {
        gas: "auto",
        gasPrice: "auto",
        url: process.env.API_KEY_RINKEBY,
        accounts: [`0x${process.env.PRIVATE_KEY}`]
    }
  }

In the KhyberFarm root, run:

npx hardhat run scripts/deployFarm.ts --network rinkeby

Todo (for school-end wrap up)

  • add connect wallet button
  • modify contract so as to see nft on opensea

About

Blockchain Staking ERC20 Token to Earn Liquidity Pool Reward Token as Tickets to Win NFT Lucky Draw on Testnets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published