Chapter 6 · Tokens · lesson 8
ERC-1155
12 min
Builds on ERC-721 and NFTs
Chapter 6 · Tokens · lesson 8
12 min
Builds on ERC-721 and NFTs
A game has 200 item types. Under ERC-721 that is 200 deployed contracts, or one collection where every sword is a distinct token with its own id and no way to say "give me fifty".
ERC-1155 solves both: one contract, many token types, each with quantities.
mapping(uint256 => mapping(address => uint256)) balanceOf;
// id account amount
One extra mapping level. That is the whole idea.
Because each id has quantities, an id can behave either way:
Same contract, same functions, same events. The distinction is a choice about supply, not a different standard.
The real selling point is batching. safeBatchTransferFrom moves many ids
in a single call.
A game handing a player ten different rewards pays for one transaction rather than ten. At scale that is not a nicety — it is the difference between a playable game and an unplayable one.
Predict
| Use case | Standard |
|---|---|
| A currency or share | ERC-20 |
| One unique thing with an identity | ERC-721 |
| Many types, some unique, some in quantity | ERC-1155 |
If you would deploy more than a handful of ERC-721 contracts that share a purpose, you probably want ERC-1155 instead.
Check