arnaucube
arnaucube/poseidon-solidity-examplePublic Self-hosted repository
poseidon-solidity-example/lib/forge-std/src/interfaces/IERC1155.sol
lib/forge-std/src/interfaces/IERC1155.solRaw
  1// SPDX-License-Identifier: MIT
  2pragma solidity >=0.6.2;
  3
  4import "./IERC165.sol";
  5
  6/// @title ERC-1155 Multi Token Standard
  7/// @dev See https://eips.ethereum.org/EIPS/eip-1155
  8/// Note: The ERC-165 identifier for this interface is 0xd9b67a26.
  9interface IERC1155 is IERC165 {
 10    /// @dev
 11    /// - Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
 12    /// - The `_operator` argument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender).
 13    /// - The `_from` argument MUST be the address of the holder whose balance is decreased.
 14    /// - The `_to` argument MUST be the address of the recipient whose balance is increased.
 15    /// - The `_id` argument MUST be the token type being transferred.
 16    /// - The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.
 17    /// - When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
 18    /// - When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
 19    event TransferSingle(
 20        address indexed _operator, address indexed _from, address indexed _to, uint256 _id, uint256 _value
 21    );
 22
 23    /// @dev
 24    /// - Either `TransferSingle` or `TransferBatch` MUST emit when tokens are transferred, including zero value transfers as well as minting or burning (see "Safe Transfer Rules" section of the standard).
 25    /// - The `_operator` argument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender).
 26    /// - The `_from` argument MUST be the address of the holder whose balance is decreased.
 27    /// - The `_to` argument MUST be the address of the recipient whose balance is increased.
 28    /// - The `_ids` argument MUST be the list of tokens being transferred.
 29    /// - The `_values` argument MUST be the list of number of tokens (matching the list and order of tokens specified in _ids) the holder balance is decreased by and match what the recipient balance is increased by.
 30    /// - When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
 31    /// - When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).
 32    event TransferBatch(
 33        address indexed _operator, address indexed _from, address indexed _to, uint256[] _ids, uint256[] _values
 34    );
 35
 36    /// @dev MUST emit when approval for a second party/operator address to manage all tokens for an owner address is enabled or disabled (absence of an event assumes disabled).
 37    event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
 38
 39    /// @dev MUST emit when the URI is updated for a token ID. URIs are defined in RFC 3986.
 40    /// The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
 41    event URI(string _value, uint256 indexed _id);
 42
 43    /// @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call).
 44    /// @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
 45    /// - MUST revert if `_to` is the zero address.
 46    /// - MUST revert if balance of holder for token `_id` is lower than the `_value` sent.
 47    /// - MUST revert on any other error.
 48    /// - MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard).
 49    /// - After the above conditions are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call `onERC1155Received` on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
 50    /// @param _from Source address
 51    /// @param _to Target address
 52    /// @param _id ID of the token type
 53    /// @param _value Transfer amount
 54    /// @param _data Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`
 55    function safeTransferFrom(address _from, address _to, uint256 _id, uint256 _value, bytes calldata _data) external;
 56
 57    /// @notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call).
 58    /// @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
 59    /// - MUST revert if `_to` is the zero address.
 60    /// - MUST revert if length of `_ids` is not the same as length of `_values`.
 61    /// - MUST revert if any of the balance(s) of the holder(s) for token(s) in `_ids` is lower than the respective amount(s) in `_values` sent to the recipient.
 62    /// - MUST revert on any other error.
 63    /// - MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).
 64    /// - Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
 65    /// - After the above conditions for the transfer(s) in the batch are met, this function MUST check if `_to` is a smart contract (e.g. code size > 0). If so, it MUST call the relevant `ERC1155TokenReceiver` hook(s) on `_to` and act appropriately (see "Safe Transfer Rules" section of the standard).
 66    /// @param _from Source address
 67    /// @param _to Target address
 68    /// @param _ids IDs of each token type (order and length must match _values array)
 69    /// @param _values Transfer amounts per token type (order and length must match _ids array)
 70    /// @param _data Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to`
 71    function safeBatchTransferFrom(
 72        address _from,
 73        address _to,
 74        uint256[] calldata _ids,
 75        uint256[] calldata _values,
 76        bytes calldata _data
 77    ) external;
 78
 79    /// @notice Get the balance of an account's tokens.
 80    /// @param _owner The address of the token holder
 81    /// @param _id ID of the token
 82    /// @return The _owner's balance of the token type requested
 83    function balanceOf(address _owner, uint256 _id) external view returns (uint256);
 84
 85    /// @notice Get the balance of multiple account/token pairs
 86    /// @param _owners The addresses of the token holders
 87    /// @param _ids ID of the tokens
 88    /// @return The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair)
 89    function balanceOfBatch(address[] calldata _owners, uint256[] calldata _ids)
 90        external
 91        view
 92        returns (uint256[] memory);
 93
 94    /// @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
 95    /// @dev MUST emit the ApprovalForAll event on success.
 96    /// @param _operator Address to add to the set of authorized operators
 97    /// @param _approved True if the operator is approved, false to revoke approval
 98    function setApprovalForAll(address _operator, bool _approved) external;
 99
100    /// @notice Queries the approval status of an operator for a given owner.
101    /// @param _owner The owner of the tokens
102    /// @param _operator Address of authorized operator
103    /// @return True if the operator is approved, false if not
104    function isApprovedForAll(address _owner, address _operator) external view returns (bool);
105}