For many, the world of NFTs is bizarre and confusing. For once people often do not understand what are possible use-cases and see only obscenely overpriced jpgs. In this article, I would like to show how we implemented premium-only content behind a paywall on nftscoring.com using our NFT tokens.
I have recently written the story how we created the NFT contract, you can read it here.
How it works
Traditionally when creating a paywall, we would need the user to create an account. Then the user would need to provide a payment method, once paid the premium content would be shown to him. With NFT we can take a different approach. The authorization to access the premium content can be delegated to ownership of a specific token. The login is done through an ethereum wallet. If the user logs in using an address that holds our NFT, we will show him the premium content. Otherwise, we will show him an option to mint one.
There are several advantages of the NFT approach to the traditional one. For once, with NFT the user is not required to create an account, he can stay anonymous to us. As his identifier will be used his ethereum address. We hence do not have to handle user authentication. Additionally, as we delegate the authorization to NFT, we do not need to store the authorized addresses either. We do not need to store anything in the database at all!
The NFT technique provides advantages from the standpoint of the user as well. He can easily sell his token on the secondary market if he decides he no longer wants to use the service.
Considering how new the ethereum ecosystem is, there is already quite a few ready to be used solutions for web3 integration. Our frontend is written in React and so we were happy to use the widely adopted Web3Modal library. This library makes it super easy to connect an ethereum wallet of the user with the website. As the name suggest it shows the user a modal overlay, prompting him to choose his preferred method of connecting a wallet.
Once the user connects his wallet, we use the web3.js library to validate whether there are is any Nft Scoring token in the wallet. This is done by interacting with the contract — calling the balanceOf method. With the web3.js library this is as easy as writing two lines of code:
If the balance of the connected wallet is positive, the premium content is unlocked.
I hope I managed to demonstrate some real-world use for NFTs. Not in some distant future, not in some parallel metaverse, but right now on the world wide web. And there are many more.
I will publish more articles introducing the web3 world from a programmer's perspective. If you are interested, do not forget to follow! 🚀
Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing
- BlockFi Review 2021: Pros, Cons and Interest Rates | CoinCodeCap
- How to Buy Bitcoin in India? 7 Best Apps to Buy Bitcoin 2021 [Mobile Version]
- Crypto Tax Software — Top 5 Best Bitcoin Tax Calculators 
- Best Crypto Hardware Wallets to Store Bitcoin  | CoinCodeCap
- Pionex Review 2021 | Free Crypto Trading Bots and Exchange
NFT use case: premium only content behind a paywall was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.