ERC-4885 Subscription NFT / multi-token standard (Subscription NFTs and Multi Tokens)

Stagnant · NFTs & multi-token · created 2022-03-08

This standard defines a way to deposit an ERC-20 token in exchange for issuing a subscription token that grants use of an NFT or multi-token for a fixed period.

Why it is needed

Subscription services such as streaming music, video, and e-books have so far been designed exclusively by centralized platforms, leaving creators and service providers with no way to build their own subscription models. Without a standardized way to handle subscriptions on-chain, each service has had to implement its own logic for subscription expiry, balance deduction, and renewal, and there has been no standard way to buy and sell subscription rights themselves, such as season passes or memberships, on secondary markets. As a result, every case requiring periodic usage rights, such as sharing streaming subscriptions, gym memberships, reselling sports season passes, or renting game items, has required building a new, mutually incompatible custom structure each time.

What to implement

In depth

Subscription registration and prerequisites

subscribeToNFT(subscriber, tokenId, uri) makes subscriber the subscriber for the given tokenId's nft and sends that nft to the subscriber's account. It must revert if the subscriber is already subscribed to the same tokenId, and must also revert if the nft has not approved the subscriptionToken contract as an operator. If tokenId is 0, it is also allowed for a new tokenId to be determined internally and minted by the nft contract. uri is optional, and if not empty, it must match the uri in the SubscribeToNFT event.

Deposit and subscription token issuance

deposit(subscriber, tokenId, depositAmount) requires that the subscriber is already subscribed to the given tokenId; it reverts otherwise, or if the nft has not approved subscriptionToken as an operator. The subscriber deposits depositAmount of the baseToken, an ERC-20, and in exchange receives subscription tokens from the subscriptionToken contract, extending the subscription period.

How subscription token balance is calculated

In the example implementation, one subscription token is issued per day of the subscription period. For example, a one-week subscription issues 7 tokens, which then decrease continuously and linearly by 1 per day down to 0 as time passes. balanceOf is a view function that computes the remaining amount at call time, and can be implemented via lazy evaluation, incurring no gas cost. For time-limited subscriptions, a linearly decreasing balance is recommended, while for permanent subscriptions, keeping the balance unchanged is recommended.

Calculating the subscription token unit price

The price the subscriber paid per token per second can be calculated from the Deposit event parameters by dividing depositAmount by (subscriptionTokenAmount x subscriptionPeriod).

Use of NFT metadata

The NFT's metadata can contain information about the asset or service that the provider offers the subscriber during the subscription period. This could be the terms of the subscription service agreed upon by both parties, or if the NFT asset itself is being provided directly, the metadata of that asset. This standard is designed generically to cover a wide range of NFT use cases.

Handling subscription expiry is left to the implementer

How to handle the case where a subscriber's subscription token balance reaches zero and the subscription expires is left to the implementer. For example, the provider could stop providing the streaming service to that subscriber, or, for an NFT representing an image stored off-chain, the uri function could be made to no longer return the metadata link.

Auto-renewal and pausing are out of scope

A feature like traditional credit-card based subscriptions, where a stored payment method automatically extends the subscription right before expiry, cannot be implemented with this proposal. This is because, when using only cryptocurrency, recurring payments require the subscriber's allowance approval each time. Additionally, this proposal does not directly handle pausing a subscription; implementers must write this themselves by inheriting a third-party contract such as OpenZeppelin's Pausable, in which case balanceOf requires additional logic and storage to reflect the paused period.

EIP-165 interface identification and ERC-20 compatibility

A contract implementing this standard must implement EIP-165's supportsInterface function, and must return true when interfaceID 0xC1A48422 is passed. name, symbol, and balanceOf are functions that already overlap with EIP-20, and implementers may optionally implement the remaining EIP-20 functions to allow subscription tokens to be transferred between subscribers or traded on secondary markets. However, the nft contract must approve the subscriptionToken address as an operator, and this standard does not affect existing NFTs that have not given such approval.

Proposal status

This ERC is currently classified as Stagnant, meaning it is a proposal that is no longer being actively discussed or developed and has stalled.

Things to watch out for

Original ERC · ← ERCs