project screenshot 1
project screenshot 2
project screenshot 3

Andsub

On-chain subscriptions as NFTs paid in ERC20 tokens

Andsub

Created At

ETHOnline 2021

Winner of

trophy

NFTPort Prize Pool

trophy

⭐️ ETHOnline 2021 Finalist

Project Description

Andsub is an on-chain platform for auto-renewable subscriptions on Ethereum. A subscription is an NFT token that's minted upon subscription and burned upon cancellation. Users can subscribe by paying in ERC20 tokens. We're providing a dashboard to manage subscriptions and a checkout page with great UX to make the subscription process easy and fast. Andsub is launched and running on Ropsten testnet.

Subscription as an NFT allows checking user access on the frontend or backend easily without any dependency on Andsub protocol and smart contracts. NFT is also a great chance for promotion for content creators and brands as subscription NFT token appears in the user's wallet.

A user can sign in to the Andsub dashboard via MetaMask to create a subscription product by setting its id, name, payable token, price, and period. A subscription product can also have metadata and image of NFT tokens associated with it. This token is minted for every subscriber upon subscription and burned upon cancellation.

By taking a subscription product id a user shares a link to checkout page https://checkout.andsub.com/andsub_demo with subscribers. The checkout page has a preview of NFT and a checkout form built by us to make it easy to sell subscriptions. We've worked a lot on checkout UI/UX. After the first token approval, a user can subscribe with one click. Potentially checkout can support multiple networks and subscriptions in different tokens (via 1inch on-chain swap). A great checkout page is valuable as it would be hard to implement, audit, and maintain it yourself.

First, a subscriber gives an unlimited allowance to Andsub smart contract. In a second transaction, they subscribe and pay for the first subscription period. Later subscription product owner will call withdrawal via Andsub contract to charge users for the next periods. Neither Andsub nor subscription product owners can benefit from an unlimited token allowance by transferring more than the subscription price per period.

There are two smart contracts. One provides subscriptions API. Another implements ERC721 NFT with rules associated with the subscription period. Currently, each user's subscription is a unique NFT token. In the future, we will replace ERC721 with ERC1155 so that each NFT token is associated with a subscription product.

Subscribers pay in payable token set in the subscription product. We've also made a prototype implementation of paying by any token. Our smart contract automatically makes on-chain swaps through Uniswap V2 pools. However, we haven't implemented that on the checkout UI.

A subscription product owner should call the withdrawal button in the dashboard to charge users for the following periods. This method transfer tokens from subscribers and renews a subscription. If a user doesn't have tokens or allowance, their subscription gets canceled and NFT gets burned. Withdrawals from multiple users are batched in a single transaction. In the future withdrawals can be called automatically by Andsub through compensating gas cost to us from subscription price.

Andsub subscription solution would be gas expensive on the Ethereum network as the number of token transfers is proportional to the number of subscribers. Initially, we plan to launch on cheaper layer 1 networks such as Polygon. However, layer 2 technologies (such as Optimism, Arbitrum, and ZK-rollups) allow building on-chain micropayments solutions with reasonable network fees. Building a subscription service on top of money streaming protocols (such as Superfluid) would require locking users and their funds in such a platform that acts as a payment channel. It complicates web3 UX even further, which is the main problem we're solving. Micropayments service has to work on popular layer 2 rollups as that's where users are going to be.

In the future, we plan to implement NFTs as ERC1155, build subscription analytics with The Graph, launch on Polygon, and start working on layer 2 solutions.

How it's Made

Andsub platform consists of 3 key components:

  1. Deployed smart contracts

  2. Dashboard dashboard.andsub.com

  3. Checkout checkout.andsub.com/andsub_demo

We've also built a demo app at app demo.andsub.com and a landing page at andsub.com.

Smart contracts are written in Solidity using OpenZeppelin, Hardhat, Waffle, and Alchemy for Ethereum RPC. Subscription NFTs are ERC721 tokens. ERC1155 would be a better choice by mapping each subscription product with a unique NFT token.

Checkout, dashboard app is built with Next.js, React, and deployed with Vercel. Frontend apps only communicate with Ethereum RPC and IPFS gateway. Most importantly, we’ve used NFTPort service to easily upload an NFT image and metadata.

We've deployed ERC20 tokens on Ropsten that anyone can mint to make it easy to test checkout. Find the "Mint tokens" button at the bottom of the checkout page.

Andsub is running on-chain and IPFS. We don't have a backend.

We've also built and deployed a landing page with Webflow.

You can find our repos on GitHub at github.com/andsubcom.

background image mobile

Join the mailing list

Get the latest news and updates