ERC-5023 · Final · ERC · 2022-01-28
ERC-5023: Shareable Non-Fungible Token
Adds a share() function to NFTs that mints a copy of a token you own for someone else while you keep yours, recording who shared what with whom as a graph of Share events.
What problem does it solve?
ERC-721 and ERC-1155 model scarce things. If you give a token away, you no longer have it. Many digital things work differently: recognition, credit, or a piece of content can be "shared" and still kept, and they may gain value as they spread.
ERC-5023 defines a minimal sharing operation for NFTs. The authors used it to model positive externalities, for example a contributor passing a merit token on to the people who helped them. The Share events form a public record of who shared with whom.
How it works
The whole interface is one function and one event:
interface IERC5023 is IERC165 {
event Share(address indexed from, address indexed to, uint256 indexed tokenId, uint256 derivedFromtokenId);
function share(address to, uint256 tokenIdToBeShared) external returns (uint256 newTokenId);
}
sharemints a new token with a fresh ID forto. The caller keeps the original.- The new token is usually a copy of the original. In the reference implementation it gets the same
tokenURI. Sharerecords the sharer, the recipient, the new ID and the ID it was derived from. Indexers can follow these links to rebuild sharing trees (Bob → Alice → Charlie, Alice → David) and wider social graphs.- ERC-165 interface ID:
0xded6338b.
Whether tokens can also be transferred is up to the implementer. If transfers are disabled, you get "shareable non-transferable" tokens that can only be minted, shared and held. That is the variant used in the reference implementation.
Sample code
A shareable, non-transferable NFT based on OpenZeppelin 5:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC721URIStorage, ERC721} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
contract ShareableMerit is ERC721URIStorage, Ownable {
event Share(address indexed from, address indexed to, uint256 indexed tokenId, uint256 derivedFromtokenId);
uint256 private _next;
constructor() ERC721("Merit", "MRT") Ownable(msg.sender) {}
function mint(address to, string calldata uri) external onlyOwner returns (uint256 id) {
id = _next++;
_mint(to, id);
_setTokenURI(id, uri);
}
function share(address to, uint256 fromId) external returns (uint256 id) {
require(ownerOf(fromId) == msg.sender, "not owner");
require(to != msg.sender, "share to someone else");
id = _next++;
_mint(to, id);
_setTokenURI(id, tokenURI(fromId));
emit Share(msg.sender, to, id, fromId);
}
// Disable transfers (mint is still allowed: from == address(0))
function _update(address to, uint256 id, address auth) internal override returns (address from) {
from = super._update(to, id, auth);
require(from == address(0), "non-transferable");
}
}
Things to know
- Status: Final.
- The standard does not limit sharing. Anyone holding a token can mint unlimited copies, so these tokens say nothing about scarcity. Add your own rules (caps, allow-lists, cooldowns) if you need them.
- The
Sharegraph is public and permanent. It shows relationships between addresses, which may matter for privacy. - The reference implementation in the EIP is marked not for production. In particular, its
setTokenURIandsetBaseURIhave no access control. - For tokens that simply cannot move, without the sharing idea, see ERC-5192 (Minimal Soulbound NFTs).