Building onchain memberships and subscriptions with Unlock Protocol
Listen Now
About This Episode
In this episode of DevNTell, Narb welcomes Julien Genestoux and Christopher Carfi from Unlock Protocol. The team provides an overview of Unlock Protocol, a smart contract-based system designed for creating on-chain memberships, subscriptions, and ticketing solutions. Unlike standard NFTs which are often perpetual, Unlock focuses on time-bound access, enabling recurring revenue models and automated expiration. Julien conducts a live coding demonstration, showing how to token-gate a blog using React and Unlock's developer tools. The session concludes with a discussion on the protocol's ecosystem, including subgraphs, checkout UIs, and advanced 'hooks' for dynamic pricing and governance.
Key Takeaways
Unlock Protocol specializes in time-bound NFTs, addressing the limitations of standard perpetual NFTs for use cases like memberships and subscriptions.
The protocol is fully open-source and community-governed, supporting over 14 different EVM-compatible networks including Linea, Polygon, and Arbitrum.
Developers can easily integrate token-gating into applications using React hooks and the Unlock Checkout UI, which supports both crypto and credit card payments via Stripe.
Advanced features like 'Hooks' allow for dynamic on-chain logic, such as bonding curves for membership pricing or cross-contract notifications upon purchase.
Unlock Protocol is already being utilized by various projects for event ticketing (e.g., DappCon, LabWeek), DAO governance (e.g., Cabin City), and loyalty programs.
Featured Guests
Episode Transcript
Read full transcriptHide transcript
All right, we're live. GM everybody. Welcome to what's going to be another great DevNTell. So if you didn't know, DevNTell is a 30-minute window for builders to showcase something they're passionate about or have been working on in Web3. It can be an awesome project you've been working on, even testing best practices, automation goodies, smart contracts, how to structure a project, etc. Basically, if you've got a passion for something, this is your opportunity to share it with the community. And today, I'm ecstatic to have the Unlock Protocol team on the show: Julien Genestoux and Chris Carfi. Welcome gang, pleasure to have you all on.
Yeah, I will start. My name is Julien Genestoux. I'm the CEO and founder here at Unlock. I am French, but I live in the US, even though this week I'm actually in Istanbul experiencing DevConnect. Really happy about all of these Turkish delights that I just had. So, excited to see everyone. And yeah, that's pretty much me.
And Chris Carfi, I head up marketing for Unlock Protocol. I've been with the project for about two years. Headed up global content and community for GoDaddy through IPO before this.
Absolutely, and I'll start by showing my screen. We're doing a quick presentation about Unlock Protocol and a quick workshop. You'll learn about the protocol, obviously, and in a second we'll do a small live coding demo with a bunch of links specifically to a GitHub repo so you can play with that. If we have time, we'll also look at some ecosystem tooling as well as other interesting things.
So, what is Unlock Protocol? Unlock is a smart contract protocol. These smart contracts can be used to create memberships, subscriptions, sell access NFTs, and the like. Use cases are many: memberships, subscriptions, including on-chain recurring subscriptions, ticketing... we ticketed a bunch of events at DevConnect this week... gaming, on-chain certifications, etc. It's an open-source project, open-source protocol. The project's been around for about five years.
The reason Julien created Unlock was there are a bunch of NFTs, but for the particular use cases of memberships and subscriptions, anything that is time-bound, regular NFTs don't work for that. You need to have a time component. These NFTs or these memberships represented by ERC-721s need to be able to expire, need to be able to do things like have recurring renewals and recurring revenue tied to those memberships.
Absolutely, and we're going to do a quick example. I'm in Istanbul this week, and the example that I'm doing is basically I created a blog... you know, anything that you can do on Medium, on WordPress, on Substack. What we want to do here in a couple of minutes is add a membership to this blog so that we can monetize it by selling access to the stories. I've created a special component called 'TokenGate' here. That component does a little bit of magic inside of this React application.
Very simply, we're using the 'useAccount' hook from our friends at wagmi. The second function is called 'useContractRead', also coming from wagmi, and it's basically reading the state of a contract. Here we're using this 'Lock' address... I'll explain in a second what is a Lock... and the function 'balanceOf', which is the normal function to retrieve the balance of a user for an NFT. Once it detects the user has a balance, it renders the content. Otherwise, it shows the checkout UI.
Great, thank you. So, I want to do a quick pause there before we get into some other things for folks who are on the comments. We've got all of the mechanisms to deploy those contracts, manage those contracts, and such. All of that is part of the open-source Unlock Protocol project. In addition, Unlock Labs, which is the organization Julien and I work for, has developed a number of convenience layer things for the protocol.
Unlock Protocol underlying smart contracts... Protocol Labs built a really cool application that you can find at labweek.io. It is basically a ticketing/events application where you can register for any of the events. When you do that, you receive an NFT that is your ticket. They actually generate QR codes that you can show at the gate. The power of using Unlock here is fantastic because they have the flexibility of using these membership contracts to airdrop or cancel if they need to.
That was excellent gang, very efficient too. So gang, for those of you watching, if you have any questions for Julien or Chris, please drop them in the comments. In the meantime, I do have a couple of questions. When you were demoing the UI, you were able to set a duration for how long the particular membership would last. Is that duration static or can you program it to be dynamic?
Good question. The duration that you program at the contract level is the duration of every single membership... say one month. But obviously, that month starts when they're minted. So if I buy mine now, it expires a month from now. If Chris buys tomorrow, his expires a month plus one day. So the duration itself is fixed in the contract, but each NFT has a different expiration date based on when it was minted.
I see. And can you apply that same construct to the price as well? For example, DAOs today for memberships run with NFTs or tokens. If a DAO wanted to introduce a temporary membership alongside lifetime ones, is that possible?
100 percent. You should price your NFT using an ERC-20 that is the DAO's token. You can make it so that a month-long membership is like X dev tokens. One thing I haven't shown in the demo which is really powerful is the concept of swap and purchase. If you don't have the specific token required for the price, the UI will show you the ability in one single transaction to pay in USDC, buy the required tokens, and get the NFT membership automatically.
Interesting. Well, that unfortunately brings us to time here, but this was a very informative talk. Thank you so much for taking the time to come on the show today and let us know about Unlock Protocol. Before people leave, how can people get in contact with you if they want to learn more?
So personally, ccarfi on all the things, but the project is at unlock-protocol.com. From there you can find our docs, our Discord, YouTube videos, and the like. Julien is @julien51 on all the things.
Listen On
Share This Episode
Share on XWatch Episodes Live!
Subscribe to our event calendar and never miss a live episode.
View Event Calendar