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-5606 introduces a way to use a single NFT to represent an asset that can be used across multiple metaverses and blockchain games.
This article translates, summarizes, and expands on the following specification.
Overview
This specification proposes a minimal standard interface for creating multiverse NFTs for digital assets such as wearables and in-game items.
If you are unfamiliar with interfaces, see the following article.
https://chaldene.net/erc721#st-toc-h-5
The proposal works by indexing the delegate NFTs on each platform where an asset exists, making them discoverable.
These platforms can include metaverses, play-to-earn games, and NFT marketplaces. The proposal builds on ERC-721 and ERC-1155 to extend their functionality.
It also allows delegate NFTs to be bundled into or unbundled from a multiverse NFT, so holders can trade them individually or together.
Motivation
Multiple platforms, such as metaverses and blockchain games, support assets based on the ERC-721 and ERC-1155 NFT standards. These include avatar wearables, weapons, shields, potions, and other in-game or metaverse items.
The main drawback is the lack of interoperability between platforms.
The same digital asset, such as an avatar, therefore needs to be released as separate ERC-721 or ERC-1155 tokens on different platforms.
Furthermore, there is no relationship between these tokens. Even if they represent the same digital asset in practice, proving the scarcity of each asset on-chain is extremely difficult.
Since NFTs were introduced, they have been described as a means of achieving interoperability and proving the scarcity of digital assets.
Although an NFT can demonstrate an item's scarcity, interoperability remains a challenge.
A multiverse NFT standard that enables ownership of digital assets across different platforms is an important first step toward interoperability and genuine ownership.
In the Web3 ecosystem, NFTs continue to evolve to represent many types of unique assets.
Owning one asset should be equivalent to owning its associated NFTs across multiple platforms.
For example, suppose a brand launches a new sneaker in several metaverses, creating a separate NFT on each platform. In practice, these NFTs all represent the same sneaker.
As metaverses and blockchain games become more widespread, it becomes necessary to express the relationships between assets on different platforms and their ability to move between them.
Addressing this problem requires a better framework for the ecosystem. The framework needs to define the relationships between assets and the nature of those associations.
Specification
The multiverse NFT contract allows digital assets on multiple platforms to be managed together.
By bundling and unbundling, the contract can hold the delegate NFT tokens representing a digital asset across several platforms.
interface IMultiverseNFT {
struct DelegateData {
address contractAddress;
uint256 tokenId;
uint256 quantity;
}
event Bundled(uint256 multiverseTokenID, DelegateData[] delegateData, address ownerAddress);
event Unbundled(uint256 multiverseTokenID, DelegateData[] delegateData);
function delegateTokens(uint256 multiverseTokenID) external view returns (DelegateData[] memory);
function unbundle(DelegateData[] memory delegateData, uint256 multiverseTokenID) external;
function bundle(DelegateData[] memory delegateData, uint256 multiverseTokenID) external;
function initBundle(DelegateData[] memory delegateData) external;
}DelegateData
A structure containing details of a delegate token.
contractAddress- Contract address of the delegate NFT.
tokenId- Token ID of the delegate NFT.
quantity- Quantity of the delegate NFT.
Bundled
An event emitted when one or more new delegate NFTs are added to a multiverse NFT.
multiverseTokenID- Token ID of the multiverse NFT.
delegateData- Array containing information about the delegate NFTs added.
ownerAddress- Address of the owner.
Unbundled
An event emitted when one or more delegate NFTs are removed from a multiverse NFT.
multiverseTokenID- Token ID of the multiverse NFT.
delegateData- Array containing information about the delegate NFTs removed.
ownerAddress- Address of the owner.
delegateTokens
Takes a multiverse NFT token ID and returns an array of data describing the delegate tokens contained in that NFT.
unbundle
Removes one or more delegate NFTs from a multiverse NFT.
It takes information identifying the delegate NFTs and transfers them from the multiverse NFT contract to the owner's address.
bundle
Adds one or more delegate NFTs to a multiverse NFT.
It takes information identifying the delegate NFTs and transfers them to the multiverse NFT contract.
The multiverse NFT contract must be authorized to transfer the delegate NFTs programmatically.
initBundle
Initializes a new bundle, creates a multiverse NFT, and grants transfer rights to the calling address.
The newly initialized multiverse NFT does not yet contain any delegate NFTs.
The function returns the token ID of the new multiverse NFT.
Further Details on the Specification
A DApp implementing this standard initializes a bundle by calling the initBundle function.
This creates a new multiverse NFT and grants transfer rights to the caller.
The delegate token contract addresses and token IDs are set when the bundle is initialized and cannot be changed afterward. This prevents unintended behavior such as unrelated NFTs accidentally being bundled together.
Once the bundle is initialized, delegate NFT tokens can be transferred to the multiverse NFT contract by calling bundle and passing the multiverse NFT's token ID.
Before the DApp calls bundle, the owner must authorize the multiverse NFT contract to transfer the delegate NFTs.
The multiverse NFT then holds one or more representations of the digital asset across different platforms.
If the owner of the multiverse NFT wishes to sell or use an individual delegate NFT on one of those platforms, they can call unbundle.
This function transfers the specified delegate NFT tokens to the calling address only if the caller is the owner of the multiverse NFT.
Rationale
The delegateData structure contains information about delegate NFT tokens on each platform. It stores contractAddress, tokenId, and quantity to distinguish the NFTs.
These NFTs must conform to the ERC-721 or ERC-1155 standard.
The bundle and unbundle functions must support partial bundling and unbundling, which is why they accept arrays of DelegateData structures.
For example, a user may initialize a bundle with three delegate NFTs but must be able to bundle or unbundle two or fewer whenever they choose.
They cannot bundle or unbundle more than the three delegate NFTs specified for the bundle.
Individual token IDs are also necessary to allow selective bundling and unbundling.
Backward Compatibility
This standard is fully compatible with ERC-721 and ERC-1155.
Reference Implementation
MultiverseNFT.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.9;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
contract ERC721Full is ERC721Enumerable, ERC721URIStorage {
/// @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
/// @param name is a non-empty string
/// @param symbol is a non-empty string
constructor(string memory name, string memory symbol)
ERC721(name, symbol)
{}
/// @dev Hook that is called before any token transfer. This includes minting and burning. `from`'s `tokenId` will be transferred to `to`
/// @param from is an non-zero address
/// @param to is an non-zero address
/// @param tokenId is an uint256 which determine token transferred from `from` to `to`
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override(ERC721Enumerable, ERC721) {
ERC721Enumerable._beforeTokenTransfer(from, to, tokenId);
}
/// @notice Interface of the ERC165 standard
/// @param interfaceId is a byte4 which determine interface used
/// @return true if this contract implements the interface defined by `interfaceId`
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC721Enumerable, ERC721)
returns (bool)
{
return
ERC721.supportsInterface(interfaceId) ||
ERC721Enumerable.supportsInterface(interfaceId);
}
/// @notice the Uniform Resource Identifier (URI) for `tokenId` token
/// @param tokenId is unit256
/// @return string of (URI) for `tokenId` token
function tokenURI(uint256 tokenId)
public
view
virtual
override(ERC721URIStorage, ERC721)
returns (string memory)
{
return ERC721URIStorage.tokenURI(tokenId);
}
function _burn(uint256 tokenId)
internal
override(ERC721, ERC721URIStorage)
{}
}
/**
* @dev Interface of the Multiverse NFT standard as defined in the EIP.
*/
interface IMultiverseNFT {
/**
* @dev struct to store delegate token details
*
*/
struct DelegateData {
address contractAddress;
uint256 tokenId;
uint256 quantity;
}
/**
* @dev Emitted when one or more new delegate NFTs are added to a Multiverse NFT
*
*/
event Bundled(
uint256 multiverseTokenID,
DelegateData[] delegateData,
address ownerAddress
);
/**
* @dev Emitted when one or more delegate NFTs are removed from a Multiverse NFT
*/
event Unbundled(uint256 multiverseTokenID, DelegateData[] delegateData);
/**
* @dev Accepts the tokenId of the Multiverse NFT and returns an array of delegate token data
*/
function delegateTokens(uint256 multiverseTokenID)
external
view
returns (DelegateData[] memory);
/**
* @dev Removes one or more delegate NFTs from a Multiverse NFT
* This function accepts the delegate NFT details, and transfer those NFTs out of the Multiverse NFT contract to the owner's wallet
*/
function unbundle(
DelegateData[] memory delegateData,
uint256 multiverseTokenID
) external;
/**
* @dev Adds one or more delegate NFTs to a Multiverse NFT
* This function accepts the delegate NFT details, and transfers those NFTs to the Multiverse NFT contract
* Need to ensure that approval is given to this Multiverse NFT contract for the delegate NFTs so that they can be transferred programmatically
*/
function bundle(
DelegateData[] memory delegateData,
uint256 multiverseTokenID
) external;
/**
* @dev Initializes a new bundle, mints a Multiverse NFT and assigns it to msg.sender
* Returns the token ID of a new Multiverse NFT
* Note - When a new Multiverse NFT is initialized, it is empty, it does not contain any delegate NFTs
*/
function initBundle(DelegateData[] memory delegateData) external;
}
abstract contract MultiverseNFT is
IMultiverseNFT,
Ownable,
ERC721Full,
IERC1155Receiver,
AccessControl
{
using SafeMath for uint256;
bytes32 public constant BUNDLER_ROLE = keccak256("BUNDLER_ROLE");
uint256 currentMultiverseTokenID;
mapping(uint256 => DelegateData[]) public multiverseNFTDelegateData;
mapping(uint256 => mapping(address => mapping(uint256 => uint256)))
public tokenBalances;
constructor(address bundlerAddress) {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(BUNDLER_ROLE, msg.sender);
_setRoleAdmin(BUNDLER_ROLE, DEFAULT_ADMIN_ROLE);
_setupRole(BUNDLER_ROLE, bundlerAddress);
}
function delegateTokens(uint256 multiverseTokenID)
external
view
returns (DelegateData[] memory)
{
return multiverseNFTDelegateData[multiverseTokenID];
}
function initBundle(DelegateData[] memory delegateData) external {
uint256 tokenId = currentMultiverseTokenID.add(1);
for (uint256 i = 0; i < delegateData.length; i = i.add(1)) {
bool isERC721 = _isERC721(delegateData[i].contractAddress);
if (isERC721) {
require(
delegateData[i].quantity == 1,
"ERC721 quantity must be 1"
);
}
multiverseNFTDelegateData[tokenId].push(delegateData[i]);
}
_incrementMultiverseTokenID();
_safeMint(msg.sender, tokenId);
}
function bundle(
DelegateData[] memory delegateData,
uint256 multiverseTokenID
) external {
require(
hasRole(BUNDLER_ROLE, msg.sender) ||
ownerOf(multiverseTokenID) == msg.sender,
"msg.sender neither have bundler role nor multiversetoken owner"
);
_bundle(delegateData, multiverseTokenID);
}
function unbundle(
DelegateData[] memory delegateData,
uint256 multiverseTokenID
) external {
require(
ownerOf(multiverseTokenID) == msg.sender,
"msg.sender is not a multiversetoken owner"
);
for (uint256 i = 0; i < delegateData.length; i = i.add(1)) {
require(
_ensureDelegateBelongsToMultiverseNFT(
delegateData[i],
multiverseTokenID
),
"delegate not assigned to multiverse token"
);
uint256 balance = tokenBalances[multiverseTokenID][
delegateData[i].contractAddress
][delegateData[i].tokenId];
require(
delegateData[i].quantity <= balance,
"quantity exceeds balance"
);
require(
_ensureMultiverseContractOwnsDelegate(delegateData[i]),
"delegate not owned by contract"
);
address contractAddress = delegateData[i].contractAddress;
uint256 tokenId = delegateData[i].tokenId;
uint256 quantity = delegateData[i].quantity;
_updateDelegateBalances(delegateData[i], multiverseTokenID);
if (_isERC721(contractAddress)) {
ERC721Full erc721Instance = ERC721Full(contractAddress);
erc721Instance.transferFrom(address(this), msg.sender, tokenId);
} else if (_isERC1155(contractAddress)) {
ERC1155Supply erc1155Instance = ERC1155Supply(contractAddress);
erc1155Instance.safeTransferFrom(
address(this),
msg.sender,
tokenId,
quantity,
""
);
}
}
emit Unbundled(multiverseTokenID, delegateData);
}
function supportsInterface(bytes4 interfaceId)
public
view
override(AccessControl, ERC721Full, IERC165)
returns (bool)
{
return
AccessControl.supportsInterface(interfaceId) ||
ERC721Full.supportsInterface(interfaceId);
}
function _bundle(
DelegateData[] memory delegateData,
uint256 multiverseTokenID
) internal {
for (uint256 i = 0; i < delegateData.length; i = i.add(1)) {
require(
_ensureDelegateBelongsToMultiverseNFT(
delegateData[i],
multiverseTokenID
),
"delegate not assigned to multiversetoken"
);
require(
_ensureDelegateQuantityLimitForMMultiverseNFT(
delegateData[i],
multiverseTokenID
),
"delegate quantity assigned to multiversetoken exceeds"
);
address contractAddress = delegateData[i].contractAddress;
uint256 tokenId = delegateData[i].tokenId;
uint256 quantity = delegateData[i].quantity;
tokenBalances[multiverseTokenID][contractAddress][
tokenId
] = tokenBalances[multiverseTokenID][contractAddress][tokenId].add(
quantity
);
if (_isERC721(contractAddress)) {
require(
quantity == 1,
"ERC721 cannot have quantity more than 1"
);
ERC721Full erc721Instance = ERC721Full(contractAddress);
erc721Instance.transferFrom(msg.sender, address(this), tokenId);
} else if (_isERC1155(contractAddress)) {
ERC1155Supply erc1155Instance = ERC1155Supply(contractAddress);
erc1155Instance.safeTransferFrom(
msg.sender,
address(this),
tokenId,
quantity,
""
);
}
}
emit Bundled(
multiverseTokenID,
delegateData,
ownerOf(multiverseTokenID)
);
}
function _ensureDelegateBelongsToMultiverseNFT(
DelegateData memory delegateData,
uint256 multiverseTokenID
) internal view returns (bool) {
DelegateData[] memory storedData = multiverseNFTDelegateData[
multiverseTokenID
];
for (uint256 i = 0; i < storedData.length; i = i.add(1)) {
if (
delegateData.contractAddress == storedData[i].contractAddress &&
delegateData.tokenId == storedData[i].tokenId
) {
return true;
}
}
return false;
}
function _ensureMultiverseContractOwnsDelegate(
DelegateData memory delegateData
) internal view returns (bool) {
if (_isERC721(delegateData.contractAddress)) {
ERC721Full erc721Instance = ERC721Full(
delegateData.contractAddress
);
if (address(this) == erc721Instance.ownerOf(delegateData.tokenId)) {
return true;
}
} else if (_isERC1155(delegateData.contractAddress)) {
ERC1155Supply erc1155Instance = ERC1155Supply(
delegateData.contractAddress
);
if (
erc1155Instance.balanceOf(
address(this),
delegateData.tokenId
) >= delegateData.quantity
) {
return true;
}
}
return false;
}
function _ensureDelegateQuantityLimitForMMultiverseNFT(
DelegateData memory delegateData,
uint256 multiverseTokenID
) internal view returns (bool) {
DelegateData[] memory storedData = multiverseNFTDelegateData[
multiverseTokenID
];
for (uint256 i = 0; i < storedData.length; i = i.add(1)) {
if (
delegateData.contractAddress == storedData[i].contractAddress &&
delegateData.tokenId == storedData[i].tokenId
) {
uint256 balance = tokenBalances[multiverseTokenID][
delegateData.contractAddress
][delegateData.tokenId];
if (
balance.add(delegateData.quantity) <= storedData[i].quantity
) {
return true;
}
return false;
}
}
}
function _updateDelegateBalances(
DelegateData memory delegateData,
uint256 multiverseTokenID
) internal returns (uint256) {
address contractAddress = delegateData.contractAddress;
uint256 tokenId = delegateData.tokenId;
tokenBalances[multiverseTokenID][contractAddress][
tokenId
] = tokenBalances[multiverseTokenID][contractAddress][tokenId].sub(
delegateData.quantity
);
return tokenBalances[multiverseTokenID][contractAddress][tokenId];
}
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external pure override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external pure override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
function _isERC1155(address contractAddress) internal view returns (bool) {
return IERC1155(contractAddress).supportsInterface(0xd9b67a26);
}
function _isERC721(address contractAddress) internal view returns (bool) {
return IERC721(contractAddress).supportsInterface(0x80ac58cd);
}
function _incrementMultiverseTokenID() internal {
currentMultiverseTokenID = currentMultiverseTokenID.add(1);
}
}Security
Because the bundle function calls external contracts, it must implement protection against reentrancy attacks.
For an explanation of reentrancy attacks, see the following article.
https://chaldene.net/solidity-reentrancy-attack
Conclusion
ERC-5606 introduces a way to create assets that can be used across several metaverses and blockchain games through a single NFT.
Further implementation details will be added in the future.
If you have questions, feel free to send me a direct message on Twitter.

