violetprotocol / ERC1238-token

Implementation of EIP-1238 for non-transferable tokens (fungible & non-fungible).
https://erc1238.notion.site/
16 stars 3 forks source link

Extension for semi-fungible tokens #4

Closed ra-phael closed 2 years ago

ra-phael commented 2 years ago

Introduces an extension to create semi-fungible tokens. They are non-fungible tokens with a shared baseId embedded in their token id using bit packing. Balances for each baseId are tracked. So for example this lets you create certificates for a course where each certificate has a unique id but one is able to lookup if an account holds a certificate for this course.

 /**
  * @dev Returns the balance of an address for a specific baseId
  */
  function balanceFromBaseId(address account, uint48 baseId) external view returns (uint256);

How values are packed in the id: [baseId (48 bits)][owner (160 bits)][counter (48 bits)]