A simple staking environment; users stake erc-20 tokens to yield ERC-1155 tokens. This contract was developed and tested with HardHat.
- User deposits NFTs to contract, worth x amount of "points" (ERC-20 "TestTokens").
- User can also increase point balance, by depositing/staking TestTokens
- If a User has enough points (meets a points threshold, they can use points to claim NFTs
- Points are accumulated at configurable emission rate
- Applied use case of ERC-1155 Multi-token Standard
- Supports staking for dedicated ERC-20 token (e.g., TestToken)
- Point emission rate proportional to staked TestTokens
- Yielding entire NFT collections or single collectibles
- Pause/resume functionality
- Supports full exit, withdrawing NFTs and TestTokens in a single transaction
- The Constructor
constructor(uint256 _emissionRate, IERC20 _testToken) public;
- Depositing NFTs
function addNFT(
address contractAddress,
uint256 id,
uint256 total,
ui external;nt256 price
) external;
- Deposit TestTokens
function deposit(uint256 _amount) external;
- Viewing Point Balance
function pointsBalance(address userAddress) public view returns (uint256);
- Claim specific NFTs for Points
function claim(uint256 _nftIndex, uint256 quantity) public;
- Claim random NFTs for points
function claimRandom() public;
- Withdraw TestTokens
function withdraw(uint256 amount) public;
- Make an Exit
function exit() external;
$ git clone https://github.com/codeamt/SolidityStakingForNFTs && cd SolidityStakingForNFTs
$ npm install
$ npx hardhat compile
$ npx hardhat test
$ npx hardhat node
$ node scripts/sample-script.js