ERC1155 is a token standard that enables a single smart contract to manage multiple token types simultaneously, including both fungible tokens (like in-game currency) and non-fungible tokens (like unique items), while also supporting batch transfers that allow moving multiple tokens to multiple recipients in one transaction, making it more efficient than ERC721 for NFT applications.
ERC-1155 Token Standard: Fungible and Non-Fungible Assets Explained
Added:in this video we're going to have a look at erc 1155 tokens we're going to talk about the definition of an erc f1155 token standard how they work how they're different from erc20 eoc 721 and how it all relates to nfts because riyadh 1155 is a popular token standard for nfts even though it can be used for other things as well first of all my name is philip and i'll be the host for this video and uh you're watching here on the miranda's channel if you haven't checked out morales yet you're building the apps you're building applications on top of crypto blockchain then you need to check out morales it's the easiest and fastest way to build dapps with that said we're going to get straight into the content previously on this channel we talked about erc 721 and how that token standard works because that is a token standard purely for nfts non-fungible tokens if you haven't watched that video yet i would watch that video before this one to get you to give you a better introduction of what an nft token standard does and how that's different from the erc20 this you know this video will be a little recap but it won't be the full it won't get get you the full understanding of what it actually is in order to kick this off let's talk about some of the things that erc 1155 um how that's different from erc 721 what it actually improved because that is what erc 1155 did it did improve on the token token standard both on the 721 and on the erc20 so if you have a look at this here we can see the eip we've talked about this many times now and the simple summary here of the eip is a standard interface for contracts that manage multiple token type types a single deployed contract may include any combination of vulnerable tokens non-fundable tokens or any other configurations and this is really the key point of erc 1155 you can now manage multiple token types in the same contract because one big problem with erc 721 was that for each new nft if it was you know okay cryptokitties that's one nft that can be one contract but then you have crypto cuties that have to create another contract um if you have you know the same owner of two projects they can create multiple different nfts in the same contract using 1155 and that means that it will take up less space on the blockchain because when this was released there was a lot of talk about how crowded the blockchain is and how much data it consumed was on and they were looking for ways to make this more efficient meaning provide the same functionality but with less space if you have fewer contracts deployed then instead we can use one contract to manage a lot of different token types then that's a win so that's what they achieved with 1155 they can now manage multiple token types from one contract and not only can they manage multiple nfts they can also have a mix of some can be nfc tokens some can be normal tokens fungible tokens and some can be a mix okay and that's you know actually a very cool idea right because you might want to mix in if you're building a game for example let's say you're building a game and you have in-game items well you want gold maybe as you know one use case for tokens that you can use as an in-game currency that is a fundable token but you also want items so you want swords you want some sort of achievements or you want special items yeah i talked about you need sword you need helmets you need pants whatever it might be in your game and those can be represented by non-fungible tokens because you don't want like oh i have a thousand pants or whatever you want to own a unique specific non-fungible token but once again if this is all confusing to you about fungible non-fungible go watch the 721 video so there's one thing that is different another thing that is different is that you can do batch transfers and that was another thing that was um sort of broken with 721 that in order to do a lot of transfers you had to do them one by one by one by one and this took up a lot of block space right and that was also an issue in the last bull run a huge issue just like it was in this bull run where the gas fees are way too high the blocks are full etc so that's why they came up with this batch transfer in 1155 so that in one single transfer you can transfer multiple nfts to multiple parties and that's also a super cool invention those points are the two points that actually are the biggest differences in terms of functionality then there is a lot of differences in how this is implemented and if you are a programmer you can find those quite interesting i'll talk a little bit about it uh later on in the video but i want to show an example here so here we have the page about 1155 from open zeppelin which is a great project by the way they provide great resources if you're a programmer uh templates for different contracts and so on and here you can see them initializing an 1155 token so first of all they have a bunch of different integers here just numbers that they name different things so they name it gold silver thor's hammer sword shield but under the hood gold is just a and name for zeros it's an alias for zero same thing with silvers and alias for one so these are just ids okay and then in the constructor here of the contract meaning what happens when this contract is created they will mint new tokens they do a bunch of mint calls and these mint calls will create new token types so they create for example gold which the second argument here is just a token id but since they did this alias they can now call it gold and they mint it to the token the contract creator here is how much they mean so 10 to the power of 18 that's a lot of tokens silver that means 10 to the power of 27 even more thor's hammer that they just meant one of so that would be a non-fundable token because there is just one of that unique kind sword they mean 10 to the power of nine this will also be a non-fungible token because it's an item it's not a currency of any sort same thing with chi shield they mean 10 to the power of 9 and then these can all be transferred and exchanged separately of one another you can transfer one and not the other and so on so this is really the power and if you later on wanted to create or meet more items you could allow for that in your contract and so this is what contracts like rare ball and all these other marketplaces uses as a base for their nfts because that allows them as a you know marketplace nft creator to allow people just create new tokens without them having to deploy new contracts over and over and over again so this is very very powerful stuff and it is the standard i would say today for nfts if you're going to build an nft today you most probably would want to use the 1155 contract i see very little reason to use the 721 token standard unless you want something that's a little bit more simple and easy to understand because i usually tell beginners when they come into solidity programming that it's easier to start to learn with 721 because the contract is a bit easier to understand but if you're actually going to deploy something that's for production 1155 is now sort of the gold standard for nfts and tokens so for those of you that are programmers let's talk a little bit about how they achieve this this mix of fungible and non-fungible tokens in terms of how they represent that inside the contract so let me draw a little bit so in a normal let's see can i zoom in here a little bit maybe so in a normal erc 721 you would have in order to represent the balances a mapping that points from token id to an address and this would mean that you can input the token id and get out the owner right so there are no um no balances here you can't own two of one token id right there's an id and there is an owner for each token id in 1155 i need some more space here now because you'll see it's a bit more complicated 1155 you have instead a mapping that points from the address or the address you want to look up that's what you have to input first and then this points to another mapping so it's a double mapping meaning you have to input two things you not only have to input the address you also have to input the token id and this will give you an integer and this integer is the balance so each token id have a balance and for those of you for those tokens that just have you know one as their limit as the thor's hammer appear there there will be other you know parts of the code that will restrict the minting of thor's hammer to only one right um and that means that even though this integer could be higher the other parts of the code won't allow it so there is just one and that will be represented here so if that were the same use case as for the 721 we can just have one then you would just mint one and that's it but the code the representation of balances can support any number of tokens so if this is how you can achieve this mix between fungible tokens non-vulnerable tokens because one address can own gold for example it was id0 you can put this balance thing uh token zero and that they could have a balance of 100 and then this person could also own thor's hammer which was id3 which would uh in this mapping you would input the address and the id3 it would give you in if that address owns that token one so they want one and this structure is pretty smart but it can be complicated for beginners with this double mapping how does that work but it's really just that you input two things into the mapping and you get the end result but it's a bit different from the 721 i hope you enjoyed this video because that's all that i was going to say about 1155. if you have any questions about this token stand or anything else that you want me to talk about please let me know in the comment section below but i appreciate you watching this video and if you like this video make sure to hit the like button and subscribe to the channel for more morales content check out morales.io for how to build dabs in a new faster better way and i want to thank you for watching i'll see you in the next video
Up Next

Solidity Programming: Complete Blockchain Developer Course
@DappUniversity
156.2K views•2020-05-22

Torrent File Format & Bencoding: A Technical Deep Dive
@AsliEngineering
12.5K views•2022-08-08

Build a DAO From Scratch: React, Python, and Solidity
@MoralisWeb3
11K views•2023-02-25

Understanding Ethereum: A Comprehensive Beginner's Overview
@99Bitcoins
3.1M views•2018-06-26
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Blockchain & Crypto





































