Skip to content

andreitoma8/ERC721-Staking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ERC721Staking Smart Contract.

Smart Contract where users can Stake their ERC721 Tokens and Owner can distribute rewards.

You can find a new and better version of a ERC721 Staking Contract with Dynamic Rewards and the option to set fixed Staking Periods and Staking Rewards in my new Repository: Synthetix ERC721 Staking. I recommend using this one.

A previous version of this Smart Contract recieved a free exploratory audit by Marco form Paladin Blockchain Security. All audit notes and issues can be found in their raw form over here. - All issues and recommendations were addressed.

Created using OpenZeppelin's ERC20 and ERC721 Smart Contracts.

This iteration of a Staking Smart Contract for ERC721 is a separate one, so you will need three SC: one for your ERC721 Collection, one for your ERC20 Token and one for the Staking Pool. You will also have to send the ERC20 Token to the Staking Smart Contract so it will be able to pay rewards for your stakers. Here are my Open Source libraries for ERC20 and ERC721 Smart Contracts.

Features for users:

  1. Deposit your ERC721 Token/s and claim a fixed amount of ERC20 Tokens calculated hourly.
  2. Withdraw your ERC721 Token/s.
  3. Withdraw rewards.

Features for owner:

  1. Distribute ERC20 Token by ERC721 Tokens Locking(Staking).
  2. Set a fixed hourly reward per ERC721 Token Locked(Staked).
  3. Change the rewards per hour

Prerequisites:

Goerli deployment
python3 -m pip install --user pipx
python3 -m pipx ensurepath
# restart terminal
pipx install eth-brownie
  • A free Infura Project Id key for Goerli Network

Instalation

Clone this repo:

git clone https://github.com/andreitoma8/ERC721-Staking
cd ERC721-Staking

Deploy to Goerli

  • Add a .env file with the same contents of .env.example, but replaced with your variables.

  • Uncomment the last line from the brownie-config.yaml file:

dotenv: .env
  • Run the command:
brownie run scripts/deploy.py --network Goerli

The script will:

  1. Deploy the ERC20 Reward Token, mint 1.000.000 for yourself and verify the Smart Contract on goerli.etherscan.io.
  2. Deploy the ERC721 NFT Collection, mint 5 Tokens for yourself and verify the Smart Contract on goerli.etherscan.io.
  3. Deploy the ERC721 Staking Smart Contract and verify it on goerli.etherscan.io.

Run the tests

Tests might fail or succed on multiple runs without changes because of the way brownie interacts with Ganache, if you want more precise tests I'd recommend working with HardHat.

To run the tests locally make sure you have Brownie and Ganache installed.

  • Runn the command:
brownie test
Any contributions much apreciated!
If this was helpful please consider donating:

0xA4Ad17ef801Fa4bD44b758E5Ae8B2169f59B666F

Happy hacking!