SuperSea - Auth & Membership

Lately, I've been fascinated by the use of NFTs and contracts for memberships and subscriptions.

One of the prime examples is SuperSea NFT for nonfungible.tools by @sbliminoid and @bobendipity.

Today I'll break down how their contract works.
1/ First of all, what is SuperSea? SuperSea is a collection of 100 NFTs that grants its holder lifetime access to nonfungible.tools member-only features.

Holding an NFT is equivalent to owning a lifetime deal. The contract also powers the tool's subscription service.
2/ First, let's see how subscription works with SuperSea's contract. It's fascinating.

As a start, the contract defines the available subscriptions in a map and defines them during contract deployment from inside the contract's constructor.
3/ Here, we see there are 2 subscription plans, the 30 days subscription at the price of 0.1 ether and 365 days subscription plan at 0.5 ether.

Auto-charging wallet is not possible within the contract. Hence offering an annual subscription at a discount is a good incentive.
4/ This is how subscription works in a smart contract. Follow on closely.

I will first share the code for you to digest before breaking it down in the next tweet.
5/ Ready? First, we get the relevant subscription plan based on its index. We know the plan exists by checking if the duration property is greater than 0.

The unit "days" is a special unit supported by the ethereum virtual machine denoting time.
6/ Then, we note down the current time using "block.timestamp". Since we know the current time, we can set the expiry date of the subscription. We do it by adding the duration of the plan to the current time.

Finally, we save and assign the expiry date to the user address.
7/ So if I'm buying the 1 monthly subscription, the contract will first check the available plans. Then it checks what time is it today (in milliseconds) and adds 1 month. Now we have the expiry date and the contract will save it and remembers that's me.
8/ A smart addition here is to check if the user had subscribed before or not. If they have, we read the expiry date of their existing subscription and add the plan duration to that instead. Then we assign the result as the new expiry date, practically extending the subscription.
9/ To check if a user has a subscription or not, we call the hasActiveSubscription function. This function is simple, we take the user's address, get the expiry date and see if it's greater than the current timestamp or not.
10/ By doing this, we can now support subscriptions and collect payment all through the blockchain! I think it's cool.

This is what SuperSea does in their website and apps to give users access.

Next, let's see how the lifetime deal works. It's actually very simple.
11/ First, we mint a token to the address. In this case, it's a simple minting function that assigns a token id to the address.

I talked about this in greater detail in my CoolCatsNFT breakdown if you want to check that out.
12/ Next, to know if someone has the NFT, we call the balanceOf() function provided by Open Zeppelin's ERC721 library to know how many tokens/NFTs an address has.

If the address has more than 0 tokens, they're a lifetime member! That's it!
13/ The NFT community has been craving for NFTs that is more than pixelated images and have a real use case.

Using NFT as a membership and smart contract for a subscription is a use case that I can see more people adopting.

I see a future where this is the default for all SaaS.
14/ Some other projects I found doing this includes:
- @pixelbeastsnft - unlocks access to tools
- @_rareblocks - lifetime access to UI blocks
- @BoredApeYC - access to THE BATHROOM
- @trends_vc - lifetime access to the newsletter
15/ For stats, this contract was a lot more expensive than the average NFT contract to deploy. It cost 0.2 ether to deploy or ~$700 based on eth price during its deployment date at 3 October 2021.
16/ ✨Free SuperSea Template✨

I created a template for those who want to build on top of SuperSea's contract. I think it's awesome to support membership and subscriptions from the blockchain.

github.com/marcelc63/supe…
17/ I'm learning web3, and writing this breakdown is my learning method.

I'll break down interesting contracts and share templates every week, same day and time.

If this interests you, follow me to get notified of the next breakdown!
18/ Check out my previous breakdown on @coolcatsnft here:

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Marcel Christianis

Marcel Christianis Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(