ERC-7634 · Final · ERC · 2024-02-22
ERC-7634: Limited Transfer Count NFT
An ERC-721 extension that records how many times each token has been transferred and blocks further transfers once a per-token limit is reached, for items that should wear out or not be flipped endlessly.
What problem does it solve?
Once an NFT is sold it can usually change hands forever. Many designs want tighter control:
- limited editions or premium auction items that should not be flipped indefinitely,
- IP that becomes free (CC0) after a set number of sales,
- game items that "wear out" after a number of trades,
- throttling high-frequency arbitrage or recursive re-staking of NFT positions.
ERC-7634 adds a simple, standard way to cap how many times a specific ERC-721 token may be transferred, without changing ERC-721 behaviour otherwise.
How it works
The interface IERC7634 has three functions and two events:
| Item | Purpose |
|---|---|
setTransferLimit(tokenId, limit) |
Set or change the cap; callable by the owner or an approved address |
transferLimitOf(tokenId) |
Read the cap |
transferCountOf(tokenId) |
Read how many transfers have happened |
TransferLimitUpdated(tokenId, previousLimit, newLimit) |
Emitted on admin changes |
TransferCountIncreased(tokenId, newCount) |
Emitted after each counted transfer |
Rules:
- Only real transfers count (
fromandtoboth non-zero). Mint and burn never increment the count. - Before a transfer, the contract checks
transferCount < transferLimitand reverts otherwise. - After a successful transfer, the count goes up by one. An implementation may do something when the cap is reached, such as burning the token.
Sample code
A hook-based implementation in the style of the reference (OpenZeppelin 4.x hooks):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
contract WearableItem is ERC721 {
event TransferCountIncreased(uint256 indexed tokenId, uint256 newCount);
event TransferLimitUpdated(uint256 indexed tokenId, uint256 previousLimit, uint256 newLimit);
mapping(uint256 => uint256) private _count;
mapping(uint256 => uint256) private _limit;
constructor() ERC721("Wearable", "WEAR") {}
function setTransferLimit(uint256 tokenId, uint256 limit) external {
require(_isApprovedOrOwner(msg.sender, tokenId), "not owner/approved");
emit TransferLimitUpdated(tokenId, _limit[tokenId], limit);
_limit[tokenId] = limit;
}
function transferLimitOf(uint256 id) external view returns (uint256) { return _limit[id]; }
function transferCountOf(uint256 id) external view returns (uint256) { return _count[id]; }
function _beforeTokenTransfer(address from, address to, uint256 id, uint256 batch) internal override {
if (from != address(0) && to != address(0)) {
require(_count[id] < _limit[id], "transfer limit reached");
}
super._beforeTokenTransfer(from, to, id, batch);
}
function _afterTokenTransfer(address from, address to, uint256 id, uint256 batch) internal override {
if (from != address(0) && to != address(0)) {
emit TransferCountIncreased(id, ++_count[id]);
}
super._afterTokenTransfer(from, to, id, batch);
}
}
Things to know
- Status: Final.
- The cap is easy to sidestep: an owner can wrap the token in another contract and trade the wrapper freely. The standard is a budgeting primitive, not an unbreakable guarantee.
- If the owner can call
setTransferLimitat any time, they can simply raise their own limit. The spec recommends making limits immutable once set, or only decreasable. - In the reference pattern a token whose limit was never set has a limit of 0, so it cannot be transferred at all until a limit is configured.
- Pairs well with burn extensions such as ERC-5679 (expire at the cap) or soulbound behaviour like ERC-5192 (lock to the final owner).