SetERC1155Compat

Git Source

Inherits: SetBase, IERC1155, IERC1155MetadataURI, IERC7572

State Variables

_approvals

mapping(address => mapping(address => bool)) private _approvals;

Functions

balanceOf

Get the balance of an account's tokens.

function balanceOf(address account, uint256 id) external view override returns (uint256);

Parameters

NameTypeDescription
accountaddress
iduint256

Returns

NameTypeDescription
<none>uint256The _owner's balance of the token type requested

balanceOfBatch

Get the balance of multiple account/token pairs

function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view returns (uint256[] memory);

Parameters

NameTypeDescription
accountsaddress[]
idsuint256[]

Returns

NameTypeDescription
<none>uint256[]The _owner's balance of the token types requested (i.e. balance for each (owner, id) pair)

setApprovalForAll

Enable or disable approval for a third party ("operator") to manage all of the caller's tokens.

MUST emit the ApprovalForAll event on success.

function setApprovalForAll(address operator, bool approved) public;

Parameters

NameTypeDescription
operatoraddress
approvedbool

isApprovedForAll

Queries the approval status of an operator for a given owner.

function isApprovedForAll(address account, address operator) public view returns (bool);

Parameters

NameTypeDescription
accountaddress
operatoraddress

Returns

NameTypeDescription
<none>boolTrue if the operator is approved, false if not

safeTransferFrom

Transfers _value amount of an _id from the _from address to the _to address specified (with safety call).

*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).

  • MUST revert if _to is the zero address.
  • MUST revert if balance of holder for token _id is lower than the _value sent.
  • MUST revert on any other error.
  • MUST emit the TransferSingle event to reflect the balance change (see "Safe Transfer Rules" section of the standard).
  • 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).*
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public;

Parameters

NameTypeDescription
fromaddress
toaddress
iduint256
amountuint256
databytes

safeBatchTransferFrom

Transfers _values amount(s) of _ids from the _from address to the _to address specified (with safety call).

*Caller must be approved to manage the tokens being transferred out of the _from account (see "Approval" section of the standard).

  • MUST revert if _to is the zero address.
  • MUST revert if length of _ids is not the same as length of _values.
  • 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.
  • MUST revert on any other error.
  • MUST emit TransferSingle or TransferBatch event(s) such that all the balance changes are reflected (see "Safe Transfer Rules" section of the standard).
  • Balance changes and events MUST follow the ordering of the arrays (_ids[0]/_values[0] before _ids[1]/_values[1], etc).
  • 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).*
function safeBatchTransferFrom(
    address from,
    address to,
    uint256[] memory ids,
    uint256[] memory amounts,
    bytes memory data
) public;

Parameters

NameTypeDescription
fromaddress
toaddress
idsuint256[]
amountsuint256[]
databytes

uri

Returns the URI for token type id. If the \{id\} substring is present in the URI, it must be replaced by clients with the actual token type ID.

function uri(uint256 id) public view override returns (string memory);

contractURI

function contractURI() external view override returns (string memory);

supportsInterface

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

function supportsInterface(bytes4 interfaceId) external pure virtual override(IERC165, SetBase) returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

_supportsInterface

function _supportsInterface(bytes4 interfaceId) internal pure returns (bool);

_uri

function _uri() internal view virtual override returns (string memory);

_uri

function _uri(uint64 id, uint32 rev) internal view virtual returns (string memory);

_safeTransferFrom

function _safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) internal;

_safeBatchTransferFrom

function _safeBatchTransferFrom(
    address from,
    address to,
    uint256[] memory ids,
    uint256[] memory amounts,
    bytes memory data
) internal;

_setApprovalForAll

function _setApprovalForAll(address owner, address operator, bool approved) internal;

_balanceOf

function _balanceOf(address account, uint256 id) internal view returns (uint256);

_postCreate

function _postCreate(uint64 id, Descriptor memory desc, bytes32[] memory elems, address owner)
    internal
    virtual
    override;

_postUpgrade

function _postUpgrade(uint64 id, Descriptor memory desc, uint32 kindRev, uint32 setRev) internal virtual override;

_postUpdate

function _postUpdate(uint64 id, Descriptor memory desc, bytes32[] memory elems) internal virtual override;

_postTouch

function _postTouch(uint64 id, Descriptor memory desc) internal virtual override;

_postTransfer

function _postTransfer(uint64 id, address from, address to) internal virtual override;

_baseURI

function _baseURI() internal view virtual returns (string memory);

Errors

InvalidTransferAmount

error InvalidTransferAmount();

TransferFromIncorrectOwner

error TransferFromIncorrectOwner();

LengthMismatch

error LengthMismatch();

ZeroAddress

error ZeroAddress();

SelfApproval

error SelfApproval();

NotOwnerNorApproved

error NotOwnerNorApproved();