Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-5643 introduces expiration and renewal mechanisms for NFT-based subscriptions. A service can use these mechanisms to require periodic renewal of access rights.
This article translates, summarizes, and expands on the following proposal.
More EIP explainers:
Overview
ERC-5643 extends ERC-721 with subscription expiration, renewal, and cancellation. An NFT can represent access to a service for a specified period, with renewal potentially requiring a payment.
Expiration concerns the subscription represented by the NFT, not ERC-721 ownership itself. An expired subscription does not automatically burn the token or transfer ownership.
Motivation
NFTs can represent DApp accounts, membership cards, and event admission passes. Ordinary ERC-721 tokens do not have a built-in expiration mechanism, even though time-limited memberships and recurring payments are common in conventional web services.
ENS
The Ethereum Name Service (ENS) provides a similar subscription model: registered names expire unless renewed. Applying a common subscription interface to NFTs makes it easier for projects to develop comparable functionality.
Improving the user experience
Managing subscriptions across multiple conventional services can be difficult. A standardized NFT subscription interface could allow a single application to display subscriptions and help users renew or cancel them.
Changing NFT revenue models
NFT issuers have historically been able to earn revenue through secondary-sale royalties. As royalty income becomes less predictable, issuers may seek recurring revenue models.
Subscription NFTs allow issuers to charge for ongoing membership or access, while giving them an incentive to continue delivering value to subscribers. The standard does not guarantee revenue or mandate a particular payment model.
Specification
ERC-5643 defines the IERC5643 interface for adding subscription functionality to NFTs.
interface IERC5643 {
/// @notice Emitted when a subscription expiration changes
/// @dev When a subscription is canceled, the expiration value should also be 0.
event SubscriptionUpdate(uint256 indexed tokenId, uint64 expiration);
/// @notice Renews the subscription to an NFT
/// Throws if `tokenId` is not a valid NFT
/// @param tokenId The NFT to renew the subscription for
/// @param duration The number of seconds to extend a subscription for
function renewSubscription(uint256 tokenId, uint64 duration) external payable;
/// @notice Cancels the subscription of an NFT
/// @dev Throws if `tokenId` is not a valid NFT
/// @param tokenId The NFT to cancel the subscription for
function cancelSubscription(uint256 tokenId) external payable;
/// @notice Gets the expiration date of a subscription
/// @dev Throws if `tokenId` is not a valid NFT
/// @param tokenId The NFT to get the expiration date of
/// @return The expiration date of the subscription
function expiresAt(uint256 tokenId) external view returns(uint64);
/// @notice Determines whether a subscription can be renewed
/// @dev Throws if `tokenId` is not a valid NFT
/// @param tokenId The NFT to get the expiration date of
/// @return The renewability of a the subscription
function isRenewable(uint256 tokenId) external view returns(bool);
}IERC5643
The interface defines the following functions and event.
SubscriptionUpdate
Emitted when the expiration of an NFT subscription changes. When the subscription is canceled, the expiration value should be set to zero.
renewSubscription
Extends an NFT subscription.
- Parameters
tokenId: The ID of the NFT.duration: The extension in seconds.
The function throws if the token ID is invalid.
cancelSubscription
Cancels an NFT subscription.
- Parameter
tokenId: The ID of the NFT.
The function throws if the token ID is invalid.
expiresAt
Returns the subscription's expiration time.
- Parameter
tokenId: The ID of the NFT.
- Return value
uint64: The subscription expiration timestamp.
The function throws if the token ID is invalid.
isRenewable
Determines whether the NFT subscription can be renewed.
- Parameter
tokenId: The ID of the NFT.
- Return value
bool: True if renewable, otherwise false.
The function throws if the token ID is invalid.
Implementation requirements
expiresAtandisRenewablecan be implemented aspureorviewfunctions.renewSubscriptionandcancelSubscriptioncan be implemented withexternalorpublicvisibility.- The
SubscriptionUpdateevent must be emitted whenever the expiration changes. supportsInterface(0x8c65f84d)must indicate support for the interface.
Additional considerations
Why a standard is needed
ERC-5643 aims to simplify NFT-based on-chain subscriptions. It defines a minimal set of functions and events rather than prescribing additional business logic.
The NFT represents subscription ownership
The NFT itself represents the subscription. No additional ERC-20 token or ERC-1155 token is required solely to represent that subscription.
Managing subscriptions
Subscription services commonly grant access or benefits for a period of time, potentially in exchange for periodic payments. The interface provides four corresponding operations.
-
Renewal (
renewSubscription)Extends the subscription period so that users can continue receiving the service.
-
Cancellation (
cancelSubscription)Allows a subscription to be terminated before its expiration, subject to the implementation's authorization rules.
-
Expiration queries (
expiresAt)Allows users to determine when a subscription expires and applications to determine whether access remains valid.
-
Renewability queries (
isRenewable)Indicates whether renewal is allowed. Some implementations may prohibit renewal after expiration, so users and applications can query this property.
The standard does not prescribe automatic recurring billing, pricing, or how an application enforces access.
Integration with existing systems
ERC-5643 extends ERC-721, allowing existing NFT systems and marketplaces to continue handling token ownership and transfers. Applications that want to display or enforce subscription-specific properties must additionally support the new interface.
Compatibility
ERC-5643 adds a small extension to the existing ERC-721 interface. Developers can retain ordinary ERC-721 functionality while implementing the subscription management functions.
Tests
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../src/ERC5643.sol";
contract ERC5643Mock is ERC5643 {
constructor(string memory name_, string memory symbol_) ERC5643(name_, symbol_) {}
function mint(address to, uint256 tokenId) public {
_mint(to, tokenId);
}
}
contract ERC5643Test is Test {
event SubscriptionUpdate(uint256 indexed tokenId, uint64 expiration);
address user1;
uint256 tokenId;
ERC5643Mock erc5643;
function setUp() public {
tokenId = 1;
user1 = address(0x1);
erc5643 = new ERC5643Mock("erc5369", "ERC5643");
erc5643.mint(user1, tokenId);
}
function testRenewalValid() public {
vm.warp(1000);
vm.prank(user1);
vm.expectEmit(true, true, false, true);
emit SubscriptionUpdate(tokenId, 3000);
erc5643.renewSubscription(tokenId, 2000);
}
function testRenewalNotOwner() public {
vm.expectRevert("Caller is not owner nor approved");
erc5643.renewSubscription(tokenId, 2000);
}
function testCancelValid() public {
vm.prank(user1);
vm.expectEmit(true, true, false, true);
emit SubscriptionUpdate(tokenId, 0);
erc5643.cancelSubscription(tokenId);
}
function testCancelNotOwner() public {
vm.expectRevert("Caller is not owner nor approved");
erc5643.cancelSubscription(tokenId);
}
function testExpiresAt() public {
vm.warp(1000);
assertEq(erc5643.expiresAt(tokenId), 0);
vm.startPrank(user1);
erc5643.renewSubscription(tokenId, 2000);
assertEq(erc5643.expiresAt(tokenId), 3000);
erc5643.cancelSubscription(tokenId);
assertEq(erc5643.expiresAt(tokenId), 0);
}
}Reference implementation
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "./IERC5643.sol";
contract ERC5643 is ERC721, IERC5643 {
mapping(uint256 => uint64) private _expirations;
constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) {}
function renewSubscription(uint256 tokenId, uint64 duration) external payable {
require(_isApprovedOrOwner(msg.sender, tokenId), "Caller is not owner nor approved");
uint64 currentExpiration = _expirations[tokenId];
uint64 newExpiration;
if (currentExpiration == 0) {
newExpiration = uint64(block.timestamp) + duration;
} else {
if (!_isRenewable(tokenId)) {
revert SubscriptionNotRenewable();
}
newExpiration = currentExpiration + duration;
}
_expirations[tokenId] = newExpiration;
emit SubscriptionUpdate(tokenId, newExpiration);
}
function cancelSubscription(uint256 tokenId) external payable {
require(_isApprovedOrOwner(msg.sender, tokenId), "Caller is not owner nor approved");
delete _expirations[tokenId];
emit SubscriptionUpdate(tokenId, 0);
}
function expiresAt(uint256 tokenId) external view returns(uint64) {
return _expirations[tokenId];
}
function isRenewable(uint256 tokenId) external pure returns(bool) {
return true;
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC5643).interfaceId || super.supportsInterface(interfaceId);
}
}The examples above are preserved from the original article. They should not be treated as verified, production-ready code. In particular, the reference implementation calls an undefined internal _isRenewable function and uses an undeclared SubscriptionNotRenewable error in the shown excerpt. The read functions also do not validate token existence as required by the interface. The renewal calculation for a previously expired, nonzero expiration may leave the subscription expired. These details require review and implementation-specific decisions before deployment.
Security
The subscription extension does not inherently change ERC-721 ownership. This separation is useful, but it does not guarantee security: implementations must enforce authorization, validate expiration and renewal behavior, and handle payments correctly.
Citation
cygaar (@cygaar), "ERC-5643: Subscription NFTs [DRAFT]," Ethereum Improvement Proposals, no. 5643, September 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5643.
Conclusion
ERC-5643 adds a common interface for representing time-limited subscriptions with NFTs, including renewal, cancellation, and expiration queries.
Questions are welcome via Twitter @cardene777.
Other publications:



