|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity ^0.8.28; |
| 3 | + |
| 4 | +/// @title Interface for hypercert token interactions |
| 5 | +/// @author bitbeckers |
| 6 | +/// @notice This interface declares the required functionality for a hypercert token |
| 7 | +/// @notice This interface does not specify the underlying token type (e.g. 721 or 1155) |
| 8 | +interface IHypercertToken { |
| 9 | + /** |
| 10 | + * AllowAll = Unrestricted |
| 11 | + * DisallowAll = Transfers disabled after minting |
| 12 | + * FromCreatorOnly = Only the original creator can transfer |
| 13 | + */ |
| 14 | + /// @dev Transfer restriction policies on hypercerts |
| 15 | + enum TransferRestrictions { |
| 16 | + AllowAll, |
| 17 | + DisallowAll, |
| 18 | + FromCreatorOnly |
| 19 | + } |
| 20 | + |
| 21 | + /// @dev Emitted when token with tokenID `claimID` is stored, with external data reference via `uri`. |
| 22 | + event ClaimStored(uint256 indexed claimID, string uri, uint256 totalUnits); |
| 23 | + |
| 24 | + /// @dev Function called to store a claim referenced via `uri` with a maximum number of fractions `units`. |
| 25 | + function mintClaim(address account, uint256 units, string memory uri, TransferRestrictions restrictions) external; |
| 26 | + |
| 27 | + /// @dev Function called to store a claim referenced via `uri` with a set of `fractions`. |
| 28 | + /// @dev Fractions are internally summed to total units. |
| 29 | + function mintClaimWithFractions( |
| 30 | + address account, |
| 31 | + uint256 units, |
| 32 | + uint256[] memory fractions, |
| 33 | + string memory uri, |
| 34 | + TransferRestrictions restrictions |
| 35 | + ) |
| 36 | + external; |
| 37 | + |
| 38 | + /// @dev Function called to split `tokenID` and transfer `to` into units declared in `values`. |
| 39 | + /// @notice The sum of `values` must equal the current value of `_tokenID`. |
| 40 | + function splitFraction(address to, uint256 tokenID, uint256[] memory _values) external; |
| 41 | + |
| 42 | + /// @dev Function called to merge tokens within `tokenIDs`. |
| 43 | + /// @notice Tokens that have been merged are burned. |
| 44 | + function mergeFractions(address account, uint256[] memory tokenIDs) external; |
| 45 | + |
| 46 | + /// @dev Function to burn the token at `tokenID` for `account` |
| 47 | + /// @notice Operator must be allowed by `creator` and the token must represent the total amount of available units. |
| 48 | + function burnFraction(address account, uint256 tokenID) external; |
| 49 | + |
| 50 | + /// @dev Function to burn the tokens at `tokenIDs` for `account` |
| 51 | + /// @notice Operator must be allowed by `creator` and the tokens must represent the total amount of available units. |
| 52 | + function batchBurnFraction(address account, uint256[] memory tokenIDs) external; |
| 53 | + |
| 54 | + /// @dev Returns the `units` held by a (fractional) token at `claimID` |
| 55 | + /// @dev If `tokenID` is a base type, the total amount of `units` for the claim is returned. |
| 56 | + /// @dev If `tokenID` is a fractional token, the `units` held by the token is returned |
| 57 | + function unitsOf(uint256 tokenID) external view returns (uint256 units); |
| 58 | + |
| 59 | + /// @dev Returns the `units` held by `account` of a (fractional) token at `claimID` |
| 60 | + /// @dev If `tokenID` is a base type, the total amount of `units` held by `account` for the claim is returned. |
| 61 | + /// @dev If `tokenID` is a fractional token, the `units` held by `account` the token is returned |
| 62 | + function unitsOf(address account, uint256 tokenID) external view returns (uint256 units); |
| 63 | + |
| 64 | + /// @dev Returns the `uri` for metadata of the claim represented by `tokenID` |
| 65 | + /// @dev Metadata must conform to { Hypercert Metadata } spec (based on ERC1155 Metadata) |
| 66 | + function uri(uint256 tokenID) external view returns (string memory metadata); |
| 67 | +} |
0 commit comments