In this post, we'll go over how the participation NFT feature works. Instead of providing a detailed description, we'll review the feature at a high level and give code pointers to the actual implementation.
Here's a simple breakdown of how the feature works:
- When listing a 1/1 NFT for auction, the creator can optionally attach a distinct participation NFT.
- Upon listing, the participation NFT will be minted as a master edition NFT with unlimited supply and transferred to an account owned by the Formfunction Gumdrop program.
- When the auction ends, an account owned by the Formfunction Gumdrop program is updated with a Merkle root that will allow each bidder to claim a participation NFT. Then, each bidder (including the winning bidder) can mint exactly one edition of the participation NFT by passing the correct Merkle proof to the program.
- After a few weeks, the master edition will be transferred back to the creator. After this point, bidders can no longer claim a participation NFT.
Check out this video for a more in-depth walkthrough.
The full program code is here.
- When listing,
new_distributor
is called. This simply initializes an account calleddistributor
. - After an auction is won,
update_distributor
is called in order to update the on-chain Merkle root. - Then, within some timespan (which can be configured), bidders can claim their participation NFT by calling
claim_edition
. This instruction takes a Merkle proof, which is validated against the Merkle root. - After some timespan, the Formfunction backend calls
close_distributor_token_account
, which returns the master edition to the creator, andclose_distributor
to reclaim rent.
- When an auction is won, a Merkle root is stored on-chain so that all bidders of the auction can claim.
- The code to process finished participation NFTs and return them to their owners is here.
- Most information about participation NFTs is stored in the
Claim
table.
- The listing code is here.
- Participation NFTs are displayed just like all other NFTs, using
NftPage.tsx
. - The code that displays participation NFTs on user profiles is here.