ERC-5496 · Last Call · ERC · 2022-07-30
ERC-5496: Multi-privilege Management NFT Extension
Attaches multiple numbered privileges (coupons, votes, airdrop rights, lounge access) to each ERC-721 token, each of which the owner can hand to another address for a limited time, optionally with shareable clones.
What problem does it solve?
Many NFTs carry real-world or onchain perks: a store discount, a DAO vote, an airdrop claim, VIP lounge access. ERC-721 only records ownership, so these perks are tracked off-chain or in separate tokens. When a project airdrops separate "perk" tokens to holders, those perks stay with the old holder if the NFT is sold. And an owner who doesn't want a perk has no standard way to pass it on without giving up the NFT.
ERC-5496 records privileges on the NFT itself, so they follow the token, and lets the owner delegate each privilege independently and temporarily.
How it works
The IERC5496 interface (ERC-165 ID 0x076e1bbb):
| Member | Purpose |
|---|---|
setPrivilege(tokenId, privilegeId, user, expires) |
Give privilege privilegeId of a token to user until expires |
privilegeExpires(tokenId, privilegeId) |
Expiry timestamp of that assignment |
hasPrivilege(tokenId, privilegeId, user) |
Whether user currently holds it |
PrivilegeAssigned event |
Emitted on every setPrivilege |
PrivilegeTotalChanged event |
Emitted when the collection's number of privileges changes |
- The collection sets a maximum number of privileges;
privilegeIdmust not exceed it. setPrivilegemay only be called by the token's owner or approved address. The interface notes sayexpiresshould be less than 30 days away.- In the spec's reference implementation, once an assignment expires the privilege falls back to the current NFT owner.
- An optional cloneable extension (
clonePrivilege(tokenId, privId, referrer), eventPrivilegeCloned) lets a holder copy a shareable privilege to someone else without losing their own, recording the referrer so a merchant can reward whoever spread a coupon. - Signature validation via ERC-1271 is recommended where signatures are involved.
Sample code
A merchant contract gating a discount on privilege #0:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IERC5496 {
function hasPrivilege(uint256 tokenId, uint256 privilegeId, address user) external view returns (bool);
function privilegeExpires(uint256 tokenId, uint256 privilegeId) external view returns (uint256);
}
contract PizzaShop {
IERC5496 public immutable membership;
uint256 public constant DISCOUNT_PRIVILEGE = 0;
constructor(IERC5496 _membership) { membership = _membership; }
function price(uint256 base, uint256 tokenId) external view returns (uint256) {
if (membership.hasPrivilege(tokenId, DISCOUNT_PRIVILEGE, msg.sender)) {
return base * 70 / 100; // 30 % off
}
return base;
}
}
The owner lending the privilege to a friend for a week (ethers v6):
const expires = Math.floor(Date.now() / 1000) + 7 * 24 * 3600;
await nft.setPrivilege(tokenId, 0, friendAddress, expires);
Things to know
- Status: Last Call. The interface is close to final but not yet Final.
- Privileges are not cleared on transfer. If a wrapper lets the owner withdraw the underlying NFT, the spec suggests blocking that until the latest privilege expiry has passed, to protect current privilege holders.
- The spec gives
expiresasuint256in the interface butuint64in the reference code; follow the interface for compatibility. - Who can set or clone privileges is the main security question, and the spec leaves it to implementers.
- For a single time-limited "user" per token, the simpler ERC-4907 may be enough; ERC-4400 defines a single non-expiring consumer role.