Know Your NFT: What is NFT standard ERC1155?



Explanation:



ERC1155, pioneered by the Enjin team, brings the idea of semi-fungibility to the NFT world. With ERC1155, IDs represent not single assets but classes of assets. For example, an ID might represent “swords”, and a wallet could own 1,000 of these swords. In this case, the balanceOf method would return the number of swords owned by a wallet, and a user can transfer any number of these swords by calling transferFrom with the “sword” ID.


interface ERC1155 { function balanceOf(address _owner, uint256 _id) external view returns (address); function transferFrom(address _from, address _to, uint256 _id, uint256 quantity) external payable; }


One advantage of this type of system is efficiency: with ERC721, if a user wanted to transfer 1,000 swords, they would need to modify the smart contract’s state (by calling the transferFrom method) for 1,000 unique tokens. With ERC1155, the developer need only call transferFrom with quantity 1,000 and perform a single transfer operation. This increased efficiency, of course, comes with the loss of information: we can no longer trace the history of an individual sword.


Note also that ERC1155 provides a superset of ERC721 functionality, meaning that an ERC721 asset could be built using ERC1155 (you’d simply have a separate ID and quantity 1 for each asset). Due to these advantages, we’ve recently witnessed growing adoption of the ERC1155 standard. OpenSea recently developed a repository on Github for getting started with the ERC1155 standard.