ERC-5643 · Stagnant · ERC · 2022-09-10
ERC-5643: Subscription NFTs
An ERC-721 extension that turns an NFT into a renewable, expiring subscription with standard functions to renew, cancel and check the expiry date.
What problem does it solve?
NFTs are often used as membership passes or app accounts, but once minted they usually last forever. Many real services need recurring payment: a membership is valid only while it is paid up. ENS names already work this way (renew or lose the name), but each project invents its own interface.
ERC-5643 standardises a small set of functions for subscription NFTs so that one wallet or dashboard can list all of a user's subscriptions, show when they expire, and renew or cancel them, regardless of which project issued them.
How it works
The token stays a normal ERC-721 (transferable, tradable). On top of that it adds:
| Function | Purpose |
|---|---|
renewSubscription(tokenId, duration) |
Extend the subscription by duration seconds; payable so the issuer can charge for it |
cancelSubscription(tokenId) |
End the subscription |
expiresAt(tokenId) |
Unix timestamp when it expires (0 if none or cancelled) |
isRenewable(tokenId) |
Whether this subscription can still be renewed |
A SubscriptionUpdate(tokenId, expiration) event must be emitted every time the expiry changes; on cancellation the expiration should be 0. Contracts must return true from supportsInterface(0x8c65f84d).
The NFT itself is the subscription: whoever holds the token holds the membership, so it can be sold or gifted with the time left on it.
Sample code
A minimal implementation based on the spec's reference contract (OpenZeppelin v4-style ERC721):
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract Membership is ERC721 {
event SubscriptionUpdate(uint256 indexed tokenId, uint64 expiration);
uint256 public constant PRICE_PER_DAY = 0.001 ether;
mapping(uint256 => uint64) private _expirations;
constructor() ERC721("Membership", "MEM") {}
function renewSubscription(uint256 tokenId, uint64 duration) external payable {
require(_isApprovedOrOwner(msg.sender, tokenId), "not owner");
require(msg.value >= (uint256(duration) * PRICE_PER_DAY) / 1 days, "underpaid");
uint64 current = _expirations[tokenId];
uint64 start = current > block.timestamp ? current : uint64(block.timestamp);
_expirations[tokenId] = start + duration;
emit SubscriptionUpdate(tokenId, start + duration);
}
function cancelSubscription(uint256 tokenId) external payable {
require(_isApprovedOrOwner(msg.sender, tokenId), "not owner");
delete _expirations[tokenId];
emit SubscriptionUpdate(tokenId, 0);
}
function expiresAt(uint256 tokenId) external view returns (uint64) {
return _expirations[tokenId];
}
function isRenewable(uint256) external pure returns (bool) {
return true;
}
function supportsInterface(bytes4 id) public view override returns (bool) {
return id == 0x8c65f84d || super.supportsInterface(id);
}
}
A service gating access simply checks expiresAt(tokenId) > block.timestamp (or the off-chain equivalent).
Things to know
- Status: Stagnant. The interface is small and usable, but the proposal has not progressed to Final.
- The standard does not say how payment works, who may renew (the reference allows owner or approved operator), or whether cancelling refunds anything. Those are implementation choices.
- Expiry does not burn or lock the token; it stays transferable. Apps must check
expiresAtthemselves. - The sample above starts renewal from "now" if the subscription has lapsed; the spec's reference adds to the old expiry instead. Pick the behaviour you want deliberately.
- For time-limited usage rights without a subscription model, see ERC-4907 and ERC-5585.