Not audited, and is a WIP
Built with Scaffold-ETH 2
LH allows anyone to create a reward event
for any ERC-721 token, in which any address that holds the NFT during the period will receive rewards.
Incentivizes users to hold NFTs that they currently own, and other users to buy an NFT if they don't hold one.
Inspiration for Loyalty Harvest
Under the hood this project consists of a few different pieces:
- an ERC-721 contract
- a claim contract
- contains a merkle root
- ECDSA recover
- and some amount of ETH or token to send to holders as reward
- off-chain script to create the Merkle tree
- off-chain script that allows user's to create a
proof
using theirleaf
and theroot
- Paul Razvan Berg's PRB Math library
For testing values for the proof of concept, see the POC.md file.
This protocol currently lives on Ethereum Sepolia, Polygon, Polygon Mumbai, and Avalanche Fuji. Additional Claim.sol
contracts will need to be deployed for this to work on more chains. Once deployed, the contract address must be added to the chainData
object inside networks.ts
.
-
Creator constructs merkle leaves based on
- an NFT contract address
- a block starting number
- a block ending number
- the total number of NFTs
-
Creator constructs merkle tree using the leaves
-
Creator calls
createRewardEvent()
function in theClaim.sol
contract with- the merkle root
- an NFT contract address
- the creator address
- reward token address
- reward token amount
- a block starting number
- a block ending number
- the total number of NFTs
- the total number of blocks NFTs were held for
-
User creates merkle proof using
- user address
- reward event Id
-
Optional: User creates signature with
- the address of who will claim it
- the reward event Id
- the NFT token Id
-
User calls
claim()
orclaimWithSignature()
to claim their rewards with input- the merkle proof
- the holder address
- the address to send rewards to
- the event Id
- the token Id
- the block you held your NFT until
- the signature if claiming from a different address from the holder