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

Some minor formatting changes and a better explanation of the split ID bits strategy. #2116

Merged
merged 91 commits into from
Jun 13, 2019
Merged
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
49fbbde
EDT-3069 Adding more clarity in transfer rules and other things, alte…
AC0DEM0NK3Y May 3, 2019
5a0fba2
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 3, 2019
73a3365
EDT-3069 id substitution example was not lowercase.
AC0DEM0NK3Y May 4, 2019
0557c37
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 4, 2019
ed9f0d1
EDT-3069 Updated the "Safe Transfer Rules" section to match feedback …
AC0DEM0NK3Y May 7, 2019
e331f58
EDT-3069 Some formatting changes to make it easier to digest/
AC0DEM0NK3Y May 7, 2019
3e2a176
EDT-3069 More formatting.
AC0DEM0NK3Y May 7, 2019
c9db596
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 7, 2019
3ba6d4f
EDT-3069 Move impl specific functions rules to the rules section.
AC0DEM0NK3Y May 7, 2019
b3f5675
EDT-3069 Better wording on impl specific api rules.
AC0DEM0NK3Y May 7, 2019
774c0ae
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 7, 2019
f745443
EDT-3069 Added in rules for TransferSingle and TransferBatch events s…
AC0DEM0NK3Y May 7, 2019
1f3a415
EDT-3069 EOA explanation.
AC0DEM0NK3Y May 8, 2019
54a4fa1
EDT-3069 Updated text after feedback.
AC0DEM0NK3Y May 9, 2019
2f16e0f
EDT-3069 Another update.
AC0DEM0NK3Y May 9, 2019
cdc350b
EDT- Minor wording changes, be consistent in how we name ERC numbers …
AC0DEM0NK3Y May 9, 2019
5083d1e
EDT-3069 Remove confusion on hook return vals and args.
AC0DEM0NK3Y May 9, 2019
5869a76
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 9, 2019
cbc7264
EDT-3069 Drop the "DRAFT" text from linked standards, so when we go f…
AC0DEM0NK3Y May 9, 2019
d5446f9
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 9, 2019
c62f69b
EDT-3069 Added safe and batch transferFrom rules to also be explicit …
AC0DEM0NK3Y May 9, 2019
dd6b5d7
EDT-3069 Another small change to match the rules.
AC0DEM0NK3Y May 9, 2019
4f36207
Changes to wording to clarify transfer rules.
JamesTherien May 10, 2019
b6f8829
Clarification for the _data parameter
JamesTherien May 10, 2019
67a42bc
Clarify rules of breaking down into multiple onReceived callbacks
JamesTherien May 10, 2019
8f0c356
Merge pull request #1 from JamesTherien/master
AC0DEM0NK3Y May 10, 2019
48cce31
EDT-3069 Alter the rejection logic back to normal for regular 115 ope…
AC0DEM0NK3Y May 10, 2019
f11b5c2
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 10, 2019
cd86485
EDT-3069 Small inconsistency and remove the ==<hex value> part from r…
AC0DEM0NK3Y May 11, 2019
206594c
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 11, 2019
d7b07bd
EDT-3069 Add in ERC-165 interface identifier info for the ERC1155Toke…
AC0DEM0NK3Y May 11, 2019
97fa9de
EDT-3069 Very minor change to text, remove odd grammar.
AC0DEM0NK3Y May 13, 2019
4f0378e
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 13, 2019
15a67ab
EDT-3069 Consistency change on the isERC1155TokenReceiver gas require…
AC0DEM0NK3Y May 13, 2019
65052c6
EDT-3069 Added wighawag as an author, alter isERC1155Receiver interfa…
AC0DEM0NK3Y May 18, 2019
8cb2756
EDT-3069 Minor grammar and consistency changes on use of "for example…
AC0DEM0NK3Y May 18, 2019
a560f91
EDT-3069 Change the recommended isERC1155TokenReceiver function to us…
AC0DEM0NK3Y May 18, 2019
2eedafb
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 18, 2019
cc3e971
EDT-3069 Small alteration to text by request.
AC0DEM0NK3Y May 21, 2019
c2a0f11
EDT-3069 Minor text consistency change.
AC0DEM0NK3Y May 22, 2019
4eaf2c7
EDT-3069 Fixed typo.
AC0DEM0NK3Y May 22, 2019
fb0e643
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 22, 2019
cc3a9d9
EDT-3069 Spelling.
AC0DEM0NK3Y May 22, 2019
caa8d27
EDT-3069 Minor formatting change.
AC0DEM0NK3Y May 22, 2019
d8b0d2f
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 22, 2019
8c96bfb
EDT-3069 Some small changes to wording for clarity.
AC0DEM0NK3Y May 24, 2019
282e0d0
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 24, 2019
50d401c
Revert magic_values to original byte4
PhABC May 24, 2019
d054f84
EDT-3069 Adding in scenario for non-standard api call and allow it to…
AC0DEM0NK3Y May 24, 2019
8d50450
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 25, 2019
eb36a93
Merge pull request #2 from PhABC/patch-7
AC0DEM0NK3Y May 25, 2019
ca3278b
EDT-3069 Minor consistency change.
AC0DEM0NK3Y May 25, 2019
cfae695
EDT-3069 Updated return value to latest after merge.
AC0DEM0NK3Y May 25, 2019
c21e799
EDT-3069 Consistency on calling "1155" "ERC-1155".
AC0DEM0NK3Y May 25, 2019
6dd5dc6
EDT-3069 Minor wording change.
AC0DEM0NK3Y May 25, 2019
343457a
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 25, 2019
91815a0
EDT-3069 More wording changes for clarification.
AC0DEM0NK3Y May 25, 2019
a3c61ba
EDT-3069 Small grammar change and capitalized API.
AC0DEM0NK3Y May 25, 2019
4ff6c62
EDT-3069 Change a MAY to SHOULD as a non-standard impl really should …
AC0DEM0NK3Y May 25, 2019
2a62512
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 25, 2019
4da1425
EDT-3069 Minor changes for grammar and consistency.
AC0DEM0NK3Y May 26, 2019
4aa3ac9
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 27, 2019
7a61926
EDT-3069 Slightly strong wording using SHOULD instead of a MAY in the…
AC0DEM0NK3Y May 27, 2019
a301bc6
EDT-3069 Solidity 0.5.9 is latest version (ref impl tested on this ve…
AC0DEM0NK3Y May 28, 2019
a9b6921
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 28, 2019
0ec4c57
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y May 28, 2019
16ad5b1
EDT-3069 Some alteration to the standard as requested along with a se…
AC0DEM0NK3Y Jun 1, 2019
eb1207b
EDT-3069 Minor grammar fix.
AC0DEM0NK3Y Jun 3, 2019
219d72a
EDT-3069 Add in mention that mint/burn is a custom transfer so follow…
AC0DEM0NK3Y Jun 4, 2019
e57d757
EDT-3069 Add in recommendation for wallets etc. to sort their batch t…
AC0DEM0NK3Y Jun 4, 2019
7800e85
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 4, 2019
8390de7
EDT-3069 More minor grammar and formatting fixes.
AC0DEM0NK3Y Jun 4, 2019
93cc841
DT-3069 Consistent use of MUST in uri event and function.
AC0DEM0NK3Y Jun 5, 2019
34df030
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 5, 2019
4f21e38
EDT-3069 Replace isERCTokenReceiver with usage of ERC165 supportsInte…
AC0DEM0NK3Y Jun 6, 2019
9de300a
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 7, 2019
463d6b2
URI event clarification
AC0DEM0NK3Y Jun 7, 2019
0a255c5
EDT-3069 Altered Metadata Extension rules to be clear about the ERC-1…
AC0DEM0NK3Y Jun 7, 2019
cb3cbfc
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 7, 2019
93a2c71
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 7, 2019
4ef4687
DT-3069 Some minor changes for github formatting.
AC0DEM0NK3Y Jun 7, 2019
7286293
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 7, 2019
dee01f7
EDT-3069 Very minor clarification.
AC0DEM0NK3Y Jun 11, 2019
b3d9945
EDT-3069 consistent use of "non-fungible" rather than mixing in "Non-…
AC0DEM0NK3Y Jun 12, 2019
92bcc27
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 12, 2019
9a29771
EDT-3069 Minor grammar alterations.
AC0DEM0NK3Y Jun 12, 2019
eb41db7
Merge branch 'master' of https://github.com/ethereum/EIPs
AC0DEM0NK3Y Jun 12, 2019
b4a5e75
EDT-3069 Formatting change for the mixed fungible strategy section an…
AC0DEM0NK3Y Jun 12, 2019
55ec8ca
EDT-3069 Very minor change to be consistent with use of "non-fungible…
AC0DEM0NK3Y Jun 12, 2019
6cffb34
EDT-3069 Minor change for grammar.
AC0DEM0NK3Y Jun 13, 2019
acf2b78
EDT-3069 Very minor formatting changes.
AC0DEM0NK3Y Jun 13, 2019
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
32 changes: 22 additions & 10 deletions EIPS/eip-1155.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,25 +652,37 @@ ERC-1155 contracts must therefore carefully emit `TransferSingle` or `TransferBa

### Non-Fungible Tokens

The following strategy is an example of how to mix fungible and non-fungible tokens together in the same contract. The top 128 bits of the uint256 `_id` parameter in any ERC-1155 function could represent the base token ID, while the bottom 128 bits might be used for any extra data passed to the contract.
The following strategies are examples of how you MAY mix fungible and non-fungible tokens together in the same contract. The standard does NOT mandate how an implementation must do this.

Non-fungible tokens can be interacted with using an index based accessor into the contract/token data set. Therefore to access a particular token set within a mixed data contract and particular NFT within that set, `_id` could be passed as `<uint128: base token id><uint128: index of NFT>`.
##### Split ID bits

Inside the contract code the two pieces of data needed to access the individual NFT can be extracted with uint128(~0) and the same mask shifted by 128.
The top 128 bits of the uint256 `_id` parameter in any ERC-1155 function MAY represent the base token ID, while the bottom 128 bits MAY represent the index of the non-fungible to make it unique.

### Example of split ID bits
Non-fungible tokens can be interacted with using an index based accessor into the contract/token data set. Therefore to access a particular token set within a mixed data contract and a particular non-fungible within that set, `_id` could be passed as `<uint128: base token id><uint128: index of non-fungible>`.

To identify a non-fungible set/category as a whole (or a fungible) you COULD just pass in the base id via the `_id` argument as `<uint128: base token id><uint128: zero>`. If your implementation uses this technique this naturally means the index of a non-fungible SHOULD be 1-based.

Inside the contract code the two pieces of data needed to access the individual non-fungible can be extracted with uint128(~0) and the same mask shifted by 128.

```solidity
uint256 baseToken = 12345 << 128;
uint128 index = 50;
uint256 baseTokenNFT = 12345 << 128;
uint128 indexNFT = 50;

uint256 baseTokenFT = 54321 << 128;

balanceOf(baseToken, msg.sender); // Get balance of the base token
balanceOf(baseToken + index, msg.sender); // Get balance of the non-fungible token index
balanceOf(baseTokenNFT, msg.sender); // Get balance of the base token for non-fungible set 12345 (this MAY be used to get balance of the user for all of this token set if the implementation wishes as a convenience).
balanceOf(baseTokenNFT + indexNFT, msg.sender); // Get balance of the token at index 50 for non-fungible set 12345 (should be 1 if user owns the individual non-fungible token or 0 if they do not).
balanceOf(baseTokenFT, msg.sender); // Get balance of the fungible base token 54321.
```

### Natural Non-Fungible tokens
Note that 128 is an arbitrary number, an implementation MAY choose how they would like this split to occur as suitable for their use case. An observer of the contract would simply see events showing balance transfers and mints happening and MAY track the balances using that information alone.
For an observer to be able to determine type (non-fungible or fungible) from an ID alone they would have to know the split ID bits format on a implementation by implementation basis.

The [ERC-1155 Reference Implementation](https://github.com/enjin/erc-1155) is an example of the split ID bits strategy.

##### Natural Non-Fungible tokens

Another simple way to represent NFTs is to allow a maximum value of 1 for each non-fungible token. This would naturally mirror the real world, where unique items have a quantity of 1, and fungible items have a quantity greater than 1.
Another simple way to represent non-fungibles is to allow a maximum value of 1 for each non-fungible token. This would naturally mirror the real world, where unique items have a quantity of 1 and fungible items have a quantity greater than 1.

## References

Expand Down