NFT ownership based login

New to WebDev/Web3… was wondering how exactly the BAYC team achieved this feature (https://boredapeyachtclub.com/#/login) Feature being, only users with any “Boring Ape” in their wallet are able to access the sites feature. Is there a best way of doing this with moralis?

thanks everyone.

Hi modnarwolf,

Yes this can be done with Moralis!

  1. Login with wallet
  2. Moralis syncs user transactions in the background
  3. Query the Moralis database for the specific NFT in EthNFTokenOwners. Subscribe to the query to get real-time notifications of changes.
  4. Conditionally display and only allow access to features if the user owns that NFT

Web3 Authentication is covered here as part of the Getting Started (also here). See Queries and Live Queries to get real-time notifications when the user purchases or sells the NFT.

There are links to helpful tutorial videos in the docs. They can also all be found on the Moralis Youtube channel.

If you plan to use React for the front end there is also a react-moralis npm package that is very handy with custom Moralis hooks.

Thank you! I appreciate your thorough response… definitely looking through some videos. :slight_smile:
I did run into this in the documentatio. is this something similar?
Im not sure i see the EthNFTokenOwners you described… :thinking: is it only within queries?

EthNFTokenOwners is the underlying table in the database which you’ll see populated in the Moralis Dashboard when a user logs in that has NFT transactions. The Moralis.Web3.getNFTs() will query this table. That will work to get the current list of NFTs owned by the user but in order to get real-time updates you’ll need to create a query and subscribe to it as described in the Live Query docs.

1 Like