Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: ERC1155 #302

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/erc1155-burnable.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= ERC-1155 Burnable
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/erc1155-metadata-uri.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= ERC-1155 Metadata Uri
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/erc1155-pausable.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= ERC-1155 Pausable
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/erc1155-supply.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= ERC-1155 Supply
1 change: 1 addition & 0 deletions docs/modules/ROOT/pages/erc1155-uri-storage.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= ERC-1155 Uri Storage
17 changes: 17 additions & 0 deletions docs/modules/ROOT/pages/erc1155.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
= ERC-1155

ERC1155 is a novel token standard that aims to take the best from previous standards to create a xref:tokens.adoc#different-kinds-of-tokens[*fungibility-agnostic*] and *gas-efficient* xref:tokens.adoc#but_first_coffee_a_primer_on_token_contracts[token contract].

TIP: ERC1155 draws ideas from all of https://docs.rs/openzeppelin_stylus/token/erc20/struct.Erc20.html[ERC20], https://docs.rs/openzeppelin_stylus/token/erc721/struct.Erc721.html[ERC721], and [ERC777].
If you’re unfamiliar with those standards, head to their guides before moving on.

== Multi Token Standard

The distinctive feature of ERC1155 is that it uses a single smart contract to represent multiple tokens at once.
This is why its [balanceOf] function differs from ERC20’s and ERC777’s: it has an additional `id` argument for the identifier of the token that you want to query the balance of.

This is similar to how ERC721 does things, but in that standard a token `id` has no concept of balance: each token is non-fungible and exists or doesn’t.
The ERC721 [balanceOf] function refers to how many different tokens an account has, not how many of each. On the other hand, in ERC1155 accounts have a distinct balance for each token `id`, and non-fungible tokens are implemented by simply minting a single one of them.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bidzyyys @qalisander @ggonzalez94 What's the uri of [balanceOf] should looks like?

Copy link
Member

@qalisander qalisander Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can reference IErc20/IErc721 trait's method like: https://docs.rs/openzeppelin_stylus/token/erc721/trait.IErc721.html#tymethod.balance_of[balanceOf]


This approach leads to massive gas savings for projects that require multiple tokens.
Instead of deploying a new contract for each token type, a single ERC1155 token contract can hold the entire system state, reducing deployment costs and complexity.
Loading