TokenGating- Grant exclusive access to owners of select NFT collections
We all know about the gated communities where the access to the facilities inside, is reserved for the members exclusively. Token-Gating is something similar to this.
Tokens/NFTs can be used to give/determine the level of access to an event or online content. there are many usecases for this. Recently there was an event where tickets were in the form of NFTs. Use your wallet and prove that you own a particular NFT and gain entry…
In this article, lets explore giving early access to a collection of NFTs for the owners of a particular set/collection of NFTs. Lets see how we can create a promotional event where if you own an NFT of a particular series, early access to purchase a new series of NFTs are provided.
So, as usual the stack is Solidity, Truffle, Ganache, VSCode, Pinata for IPFS…the code repo is here.
Overall structure of the code
We will be using Openzepplin’s ERC721 as the base code and build over that. we shall define 2 structs named “collection” and “promo”.
Struct collection will have a name and array of ids of NFTs. Struct promo will have a promo name, and 2 arrays for collections of eligible collections to gain access to the Early access collections stored in the 2nd array.
you can access the code on Github here.
Next, for any visitor visiting the gallery, we shall collate the collections of NFTs he owns and pick the promos he is eligible for. On click of show Early Access NFTs, we shall display the NFTs which he can buy before the release.
For demo purposes, below is the context.
we will have 4 NFT collections
Series A has tokenIds 0 and 1
Series B has tokenIds 2 and 3
Series C has tokenIds 4 and 5
Series D has tokenIds 6 and 7
we shall create 2 promotions
- for owners of collection A, access will be given to purchase collection C
- for owners of collection B, access will be given to purchase collection D
The following demo has the user owning a series- A collection as shown below.
on fetching Early access collections, he gets early access to series-C collections
similarly user with Series-B has access to Series-D. notice the account addresses on the bottom right corners in these images.
For further peek into the code please visit Github.
So, this was one use case where ownership of NFT can be used as an access pass or ticket to an exclusive offer/access
Feel free to contact me on my linkedIn.
- What are the Trading Signals? | Bitstamp vs Coinbase | Buy Solana
- ProfitFarmers Review | How to use Cornix Trading Bot
- 10 Best Cryptocurrency Blogs | YouHodler Review
- MyConstant Review | 8 Best Swing Trading Bots
- MXC Exchange Review | Pionex vs Binance | Pionex Arbitrage Bot
- My Experience with Crypto Copy Trading | Coinbase Review
- CoinFLEX Review | AEX Exchange Review | UPbit Review
- AscendEx Margin Trading | Bitfinex Staking | bitFlyer Review