← Kevin M Thazhathoot

NFT Subscription Management

2022 ยท Next.js, Solidity, Hardhat, ethers.js, Firebase

A Medium-style reading app where you pay per article with NFTs instead of a monthly subscription. Writers publish articles, and readers spend a daily pass to unlock each one.


How it works

  1. A reader connects their MetaMask wallet and mints up to 10 passes for the day.
  2. Opening an article burns one of today's passes and unlocks it.
  3. Unlocked articles are remembered in Firestore, so you never pay twice for the same one.

Why ERC-1155

Most NFTs follow ERC-721, where every token is unique, like a numbered collectible. ERC-1155 lets one contract hold many token types, with many identical copies of each, which fits a pass much better.

The interesting part is the token ID: it's the day number (block.timestamp / 1 days). Passes minted today are one token type, tomorrow's are another. The app only checks today's type, so yesterday's passes expire on their own, with no cleanup job and no expiry field. And every day lives in one cheap contract instead of a new NFT per pass.


Status

It ran on Ethereum's Rinkeby test network, which has since been shut down, so there is no live demo. The code is on GitHub.

github.com/kevinmt24/NFT-Subscription-Management