ERC1155Compatible

Git Source

Inherits: SetSolo, IERC1155, IERC1155MetadataURI, IERC7572

A minimal ERC-1155 wrapper for object tokens in a Set, where each object has a quantity of exactly 1.

Extends SetSolo and conforms to IERC1155, IERC1155MetadataURI, and IERC7572.

State Variables

_approvals

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

Functions

balanceOf

Returns the value of tokens of token type id owned by account.

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

balanceOfBatch

*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. Requirements:

  • accounts and ids must have the same length.*
function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view returns (uint256[] memory);

setApprovalForAll

*Grants or revokes permission to operator to transfer the caller's tokens, according to approved, Emits an {ApprovalForAll} event. Requirements:

  • operator cannot be the zero address.*
function setApprovalForAll(address operator, bool approved) public;

isApprovedForAll

Returns true if operator is approved to transfer account's tokens. See {setApprovalForAll}.

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

safeTransferFrom

*Transfers a value amount of tokens of type id from from to to. WARNING: This function can potentially allow a reentrancy attack when transferring tokens to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver. Ensure to follow the checks-effects-interactions pattern and consider employing reentrancy guards when interacting with untrusted contracts. Emits a {TransferSingle} event. Requirements:

  • to cannot be the zero address.
  • If the caller is not from, it must have been approved to spend from's tokens via {setApprovalForAll}.
  • from must have a balance of tokens of type id of at least value amount.
  • If to refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value.*
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes memory data) public;

safeBatchTransferFrom

*xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. WARNING: This function can potentially allow a reentrancy attack when transferring tokens to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver. Ensure to follow the checks-effects-interactions pattern and consider employing reentrancy guards when interacting with untrusted contracts. Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. Requirements:

  • ids and values must have the same length.
  • If to refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value.*
function safeBatchTransferFrom(
    address from,
    address to,
    uint256[] memory ids,
    uint256[] memory amounts,
    bytes memory data
) public;

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

Returns a URI pointing to contract-level metadata

The metadata should conform to a standard like OpenSea's contract-level metadata schema

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

Returns

NameTypeDescription
<none>stringuri_ The contract metadata URI as a string

supportsInterface

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] to learn more about how these ids are created. This function call must use less than 30 000 gas.

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

_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(address owner, uint64 id, Descriptor memory od, bytes32[] memory elems)
    internal
    virtual
    override;

_postUpgrade

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

_postUpdate

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

_postTouch

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

_postTransfer

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

_supportsInterface

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

_tokenURI

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

_contractURI

function _contractURI() 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();