Redeeming Onchain Points
Although points accrued on a Badge NFT only go up (or zeroed out on token burn), they can be redeemed for perks such as NFTs, protocol unlocks or generally any offchain perk (ex: https://perk.shop).
Once points are redeemed, the user must accrue new points for other redemptions.
The general flow is
User accrues points against their badge NFT
We can check their redeemable points via our peripheral contract
SBTRedemption
We can redeem some of their points by sending a signed struct to
SBTRedemption#redeemRewardUnits
On successful tx, proceed with the redemption (onchain or offchain)
How to redeem onchain points for perks
We're going to offer an API to make everything easier, but the whole process can be done client-side with a connected badge holder's wallet client.
SBTRedemption contract (Polygon) | 0x5d324d9fbb924a909B89d9cF6F311385B80477DF
SBTRedemption contract interface | https://github.com/mad-finance/madfi-protocol-public/blob/master/contracts/interfaces/ISBTRedemption.sol
The full, self-contained React hook for fetching redeemable points + redeeming onchain can be found in this gist: https://gist.github.com/imthatcarlos/379cb5c4b3b3851dc714800dc222d378
Here is a preview of the code to get a signed struct, and sending the redemption onchain
That's it! 🚀 The token holder's onchain points have been redeemed and the perks provider can continue with the fulfillment.
Last updated