-
Notifications
You must be signed in to change notification settings - Fork 2
OpenZeppelin Configuration
Sasha Boginsky edited this page May 8, 2023
·
1 revision
https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155
This set of interfaces and contracts are all related to the ERC1155 Multi Token Standard. ERC1155 implements the mandatory IERC1155
interface, as well as the optional extension IERC1155MetadataURI
, by relying on the substitution mechanism to use the same URI for all token types, dramatically reducing gas costs.
Additionally there are multiple custom extensions, including:
- designation of addresses that can pause token transfers for all users (
ERC1155Pausable
). - destruction of own tokens (
ERC1155Burnable
).
balanceOf(address, id)
balanceOfBatch(accounts, ids)
setApprovalForAll(operator, approved)
isApprovedForAll(account, operator)
safeTransferFrom(from, to, id, amount, data)
safeBatchTransferFrom(from, to, ids, amounts, data)
-
uri(uint256 id) → string
- 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.
- Returns the URI for token type
constructor(string uri_)
supportsInterface(interfaceId)
-
uri(_) -> string
- This implementation returns the same URI for all token types. It relies on the token type ID substitution mechanism defined in the EIP. Clients calling this function must replace the
{id}
substring with the actual token type ID.
- This implementation returns the same URI for all token types. It relies on the token type ID substitution mechanism defined in the EIP. Clients calling this function must replace the
-
balanceOf(account, id) -> uint256
- getting the balance of the token by entering the address and token id. balanceOfBatch(accounts, ids)
setApprovalForAll(operator, approved)
isApprovedForAll(account, operator)
safeTransferFrom(from, to, id, amount, data)
safeBatchTransferFrom(from, to, ids, amounts, data)
-
_safeTransferFrom(from, to, id, amount, data)
- transfersamount
tokens of token typeid
fromfrom
toto
.-
from
should be deployer address -
to
should be a different address
-
_safeBatchTransferFrom(from, to, ids, amounts, data)
-
_setURI(string newuri)
- sets a new URI for all token types, by relying on the token type ID substitution mechanism defined in the EIP.- By this mechanism, any occurrence of the
{id}
substring in either the URI or any of the amounts in the JSON file at said URI will be replaced by clients with the token type ID.- For example, the
https://token-cdn-domain/{id}.json
URI would be interpreted by clients ashttps://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json
for token type ID 0x4cce0.
- For example, the
- Because these URIs cannot be meaningfully represented by the
uri
event, this function emits no events.
- By this mechanism, any occurrence of the
-
_mint(address to, uint256 id, uint256 amount, bytes data)
- createsamount
tokens of token typeid
, and assigns them toto
.- Emits a
TransferSingle
event. -
to
cannot be the zero address. - If
to
refers to a smart contract, it must implementIERC1155Receiver.onERC1155Received
and return the acceptance magic value.
- Emits a
-
_mintBatch(to, ids, amounts, data)
- Emits a
TransferBatch
event.
- Emits a
_burn(from, id, amount)
_burnBatch(from, ids, amounts)
_setApprovalForAll(owner, operator, approved)
_beforeTokenTransfer(operator, from, to, ids, amounts, data)
-
Name: RPS
- function:
name() -> string
- returns the token collection name.
- function:
-
URI: https://ipfs.io/ipfs/bafybeicxlrrqm5l6uqtngfmdgrzzqrklu2vdqwg3dx32fcqpffh7qyryju/{id}.json
- Location of the metadata. Clients will replace any instance of
{id}
in this string with thetokenId
.
- Location of the metadata. Clients will replace any instance of
- Mintable: privileged accounts will be able to create more supply.
- Burnable (extension -
ERC1155Burnable
): token holders will be able to destroy their tokens. - Pausable (extension -
ERC1155Pausable
): privileged accounts will be able to pause the functionality marked aswhenNotPaused
. Useful for emergency response. - Supply Tracking (core -
ERC1155Supply
): keeps track of total supply of tokens.
- Ownable: simple mechanism with a single account authorized for all privileged actions. (
Ownable
) - Access Control: supports multiple accounts authorized for various priviledged actions designated by roles. (
AccessControl
)