Bnb bootcamp final project
GenXLocker DApp provides its users with the option of locking up their ERC20 tokens in order to gain rewards.
This is a simple staking DApp that allows the user to stake a specified token for a given time period and earn rewards from that stake.
- The staking is not pooled and each stake operates independently of the other stakes in the contract.
- A single user can stake multiple time and different tokens at the same time and each stake will have its own duration, APY and rewards without combining or interfering with other stakes.
- Support for new stake tokens is dynamic. That is, the contract owner can add Support for new tokens that adhere to the IERC20 specifications without having to modify the contract.
- Tokens can only be unstaked after the specified duration.
- EVM Wallet Integration: Connect your Ethereum wallet (e.g., MetaMask) to participate directly.
The target deployment chain is Binance smart chain, although the contract should be usable on most EVM chains.
- MetaMask browser extension. The client-side relies on the availability of web3.js and MetaMask web3 service. This should be available if MetaMask is installed on thr browser.
-
Upload the web folder to your web server and access the index.html file to open the DApp.
-
It is best to re-compile the smart contract and redeploy it so as to establish yourself as the contract owner. This is necessary because certain functions, such as addStakeToken(), are only accessible by the contract owner.
-
Update the contract address and ABI variables in the web/js/dappconst.js file to match your deployment details.
-
Open your browser and navigate to the proper URL to access the DApp. The URL should point to the index.html file in the web folder
-
Connect your Metamask wallet to the DApp.
-
Lock your tokens.
-
View your stakes and rewards.
There are two smart contracts used by this DApp. These are;
Ownable.sol
: Defines the implementation for the owner only modifier.GenXLocker.sol
: Contains all the major functions required by the DApp.
Smart contract tests are located in the test
folder. These tests ensure the correct functioning of the smart contract.
The Frontend consists of a simple UI built using HTML and JavaScript. The frontend is a demo to test and show the functionality of the smart contract. Each primary function of the smart contract can be accessed via the corresponding section in the dApp.
This project is licensed under the MIT License.
This is my first smart contract and dApp so the contracts and integration may not really be optimal since I'm still learning the nuances of Solidity development and deployment. The code is available to use, modify, upgrade, etc for whatever purpose.