ERC-4341 An ordered NFT bundle standard (Ordered NFT Batch Standard)
Stagnant · NFTs & multi-token · created 2021-10-01
Preserves the original order when transferring multiple NFTs, so that tokenIds encoded in Unicode, such as Chinese characters or emoji, can be exchanged as meaningful phrases.
Why it is needed
Because ERC-721 and ERC-1155 treat NFTs as units of an asset, transferring multiple NFTs at once does not preserve or store their order; it is discarded. But when the tokenId itself is used as a Unicode character, as in EIP-3754, sending multiple tokens becomes the act of conveying a sentence or word. If the order changes, the meaning becomes completely different. For example, the Unicode values of the two characters meaning the Great Wall, (38271, 22478), and the reversed order (22478, 38271), read as '长城' and '城长' respectively, both real Chinese words but with different meanings. ERC-1155's batch transfer has no way to restore this order, so it has not been possible to standardize sending and receiving logographic characters like Chinese characters or emoji on the blockchain with their meaning intact.
What to implement
event Transfer(address indexed from, address indexed to, uint256 id, uint256 amount);: Signals that a single token was transferred from `from` to `to` in the amount of `amount`.event TransferBatch(address indexed from, address indexed to, uint256[] ids, uint256[] amounts);: Signals that multiple tokens were transferred at once in a batch.event ApprovalForAll(address indexed owner, address indexed operator, bool approved);: Signals that `operator` has been granted or revoked authority to manage all of `owner`'s tokens on their behalf.function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;: Transfers a single token from `from` to `to` in the amount of `amount`.function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;: Transfers multiple tokens at once according to `ids` and `amounts`.function safePhraseTransferFrom(address from, address to, uint256[] calldata phrase, bytes calldata data) external;: Transfers an ordered array of tokens, a phrase, from `from` to `to` while preserving order.function balanceOf(address owner, uint256 id) external view returns (uint256);: Looks up the quantity of a specific id token held by `owner`.function balanceOfPhrase(address owner) external view returns (uint256);: Looks up the number of phrases held by `owner`.function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) external view returns (uint256[] memory);: Looks up balances for multiple owner and id combinations at once.function retrievePhrase(address owner, uint256 phraseId) external view returns (uint256[] memory);: Looks up a stored phraseId and returns the original ordered Unicode (token id) array.function setApprovalForAll(address operator, bool approved) external;: Grants or revokes an operator's authority to manage all of one's tokens on their behalf.function isApprovedForAll(address owner, address operator) external view returns (bool);: Checks whether `operator` has authority to manage `owner`'s tokens on their behalf.
In depth
The phrase structure
A phrase consists of a few base characters, that is, an ordered Unicode sequence, and is stored as an array of unsigned integers. A phrase itself is not something that is circulated (transferred); it does not increase or decrease the balance of any NFT. A phrase cannot be transferred, but it can be looked up and decoded to restore the original Unicode sequence. Because this information is kept in contract storage, it requires additional storage beyond what ERC-1155 needs.
Why order determines meaning
The two Chinese characters in 长城 (the Great Wall) have Unicode decimal values of 38271 and 22478 respectively. Combining them in the order (38271, 22478) gives 长城, but combining them in the order (22478, 38271) gives 城长, an entirely different word. Both are words actually used in Chinese. This is presented as the core difference between this standard and ERC-1155.
The difference between safePhraseTransferFrom and a regular batch transfer
safeBatchTransferFrom takes ids and amounts arrays in the same way as ERC-1155 to transfer multiple tokens, but it provides no guarantee that order is preserved. safePhraseTransferFrom, by contrast, takes an ordered array called phrase as its argument and preserves and stores that order itself during the transfer. Separate functions, balanceOfPhrase and retrievePhrase, are added to query this.
Prerequisite standard EIP-3754
This standard requires EIP-3754 as a precondition. EIP-3754 is a standard that treats NFTs as basic units on the blockchain and proposes that a tokenId encoded in Unicode can carry abstract meaning. In other words, this standard builds on the assumption that each individual tokenId already represents a single Unicode character, adding on top of that a function for managing the order of multiple tokenIds.
Scope of application and limitations
This standard is described as suitable for logographic languages (languages in which a single character represents a word or morpheme) such as Chinese hanzi, Japanese kanji, and Korean hanja, as well as emoji. In these writing systems, only a few characters can convey rich meaning, which makes standardization worthwhile. Non-logographic languages like English, on the other hand, are stated to gain little practical benefit, since representing each individual letter as an NFT would be cumbersome.
Proposal status: Stagnant
This ERC is currently in Stagnant status, meaning the proposal is no longer actively discussed or advanced and has stalled. This should be taken into account when considering adoption or implementation of the standard.