github.com/status-im/status-go@v1.1.0/contracts/ierc1155/ierc1155.sol (about)

     1  pragma solidity ^0.5.16;
     2  
     3  /**
     4      @title ERC-1155 Multi Token Standard
     5      @dev See https://eips.ethereum.org/EIPS/eip-1155
     6      Note: The ERC-165 identifier for this interface is 0xd9b67a26.
     7   */
     8  /* is ERC165 */ interface ERC1155 {
     9      /**
    10          @dev 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).
    11          The `_operator` argument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender).
    12          The `_from` argument MUST be the address of the holder whose balance is decreased.
    13          The `_to` argument MUST be the address of the recipient whose balance is increased.
    14          The `_id` argument MUST be the token type being transferred.
    15          The `_value` argument MUST be the number of tokens the holder balance is decreased by and match what the recipient balance is increased by.
    16          When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
    17          When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).        
    18      */
    19      event TransferSingle(
    20          address indexed _operator,
    21          address indexed _from,
    22          address indexed _to,
    23          uint256 _id,
    24          uint256 _value
    25      );
    26  
    27      /**
    28          @dev 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).      
    29          The `_operator` argument MUST be the address of an account/contract that is approved to make the transfer (SHOULD be msg.sender).
    30          The `_from` argument MUST be the address of the holder whose balance is decreased.
    31          The `_to` argument MUST be the address of the recipient whose balance is increased.
    32          The `_ids` argument MUST be the list of tokens being transferred.
    33          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.
    34          When minting/creating tokens, the `_from` argument MUST be set to `0x0` (i.e. zero address).
    35          When burning/destroying tokens, the `_to` argument MUST be set to `0x0` (i.e. zero address).                
    36      */
    37      event TransferBatch(
    38          address indexed _operator,
    39          address indexed _from,
    40          address indexed _to,
    41          uint256[] _ids,
    42          uint256[] _values
    43      );
    44  
    45      /**
    46          @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).        
    47      */
    48      event ApprovalForAll(
    49          address indexed _owner,
    50          address indexed _operator,
    51          bool _approved
    52      );
    53  
    54      /**
    55          @dev MUST emit when the URI is updated for a token ID.
    56          URIs are defined in RFC 3986.
    57          The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
    58      */
    59      event URI(string _value, uint256 indexed _id);
    60  
    61      /**
    62          @notice Transfers `_value` amount of an `_id` from the `_from` address to the `_to` address specified (with safety call).
    63          @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
    64          MUST revert if `_to` is the zero address.
    65          MUST revert if balance of holder for token `_id` is lower than the `_value` sent.
    66          MUST revert on any other error.
    67          MUST emit the `TransferSingle` event to reflect the balance change (see "Safe Transfer Rules" section of the standard).
    68          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).        
    69          @param _from    Source address
    70          @param _to      Target address
    71          @param _id      ID of the token type
    72          @param _value   Transfer amount
    73          @param _data    Additional data with no specified format, MUST be sent unaltered in call to `onERC1155Received` on `_to`
    74      */
    75      function safeTransferFrom(
    76          address _from,
    77          address _to,
    78          uint256 _id,
    79          uint256 _value,
    80          bytes calldata _data
    81      ) external;
    82  
    83      /**
    84          @notice Transfers `_values` amount(s) of `_ids` from the `_from` address to the `_to` address specified (with safety call).
    85          @dev Caller must be approved to manage the tokens being transferred out of the `_from` account (see "Approval" section of the standard).
    86          MUST revert if `_to` is the zero address.
    87          MUST revert if length of `_ids` is not the same as length of `_values`.
    88          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.
    89          MUST revert on any other error.        
    90          MUST emit `TransferSingle` or `TransferBatch` event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).
    91          Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
    92          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).                      
    93          @param _from    Source address
    94          @param _to      Target address
    95          @param _ids     IDs of each token type (order and length must match _values array)
    96          @param _values  Transfer amounts per token type (order and length must match _ids array)
    97          @param _data    Additional data with no specified format, MUST be sent unaltered in call to the `ERC1155TokenReceiver` hook(s) on `_to`
    98      */
    99      function safeBatchTransferFrom(
   100          address _from,
   101          address _to,
   102          uint256[] calldata _ids,
   103          uint256[] calldata _values,
   104          bytes calldata _data
   105      ) external;
   106  
   107      /**
   108          @notice Get the balance of an account's tokens.
   109          @param _owner  The address of the token holder
   110          @param _id     ID of the token
   111          @return        The _owner's balance of the token type requested
   112       */
   113      function balanceOf(
   114          address _owner,
   115          uint256 _id
   116      ) external view returns (uint256);
   117  
   118      /**
   119          @notice Get the balance of multiple account/token pairs
   120          @param _owners The addresses of the token holders
   121          @param _ids    ID of the tokens
   122          @return        The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair)
   123       */
   124      function balanceOfBatch(
   125          address[] calldata _owners,
   126          uint256[] calldata _ids
   127      ) external view returns (uint256[] memory);
   128  
   129      /**
   130          @notice Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.
   131          @dev MUST emit the ApprovalForAll event on success.
   132          @param _operator  Address to add to the set of authorized operators
   133          @param _approved  True if the operator is approved, false to revoke approval
   134      */
   135      function setApprovalForAll(address _operator, bool _approved) external;
   136  
   137      /**
   138          @notice Queries the approval status of an operator for a given owner.
   139          @param _owner     The owner of the tokens
   140          @param _operator  Address of authorized operator
   141          @return           True if the operator is approved, false if not
   142      */
   143      function isApprovedForAll(
   144          address _owner,
   145          address _operator
   146      ) external view returns (bool);
   147  }