ERC1155Base
ERC1155Base
Inherits: AccessControl, ERC1155Burnable, ERC1155Royalty, ERC1155Metadata_URI, ERC1155Supply
Author: cosimo.demedici.eth *
Self-sovereign ERC-1155 minter preset *
State Variables
MINTER_ROLE
MINTER_ROLE is needed in case the deployer may want to use or allow other accounts to mint on their self-sovereign collection.
bytes32 internal constant MINTER_ROLE = 0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6;CURATOR_ROLE
CURATOR_ROLE is needed in case the deployer may want to use or allow other accounts to curate on their self-sovereign collection.
bytes32 internal constant CURATOR_ROLE = 0x850d585eb7f024ccee5e68e55f2c26cc72e1e6ee456acf62135757a5eb9d4a10;FACTORY
Constant set at deployment of master contract, replaces initializer modifier reducing the cost of calling initialize from the factory contract when a new clone is deployed.
address internal immutable FACTORY;Functions
mint
Creates amount new tokens for to, of token type id.
mint() cannot be called in order to increase the supply of an existing token Id, this is in order to avoid a very complex contract logic for establishing a maximum supply cap per token. I.e. the maximum tokenId supply is implicitly enforced by the fact that a new tokenId is created each time mint() is called.
Parameters
_to
address
if different from msg.sender it is considered an airdrop
_value
uint256
_data
bytes
is used to pass the tokenURI which is the ipfs hash of the token, base58 decoded, then the first two bytes "Qm" removed, then hex encoded and in order to fit exactly in 32 bytes (uint256 is 32 bytes). const getBytes32FromIpfsHash = hash => { let bytes = bs58.decode(hash); bytes = bytes.slice(2, bytes.length); let hexString = web3.utils.bytesToHex(bytes); return web3.utils.hexToNumber(hexString); };
_mint
super._mint calls parent functions from the most derived to the most base contract: ERC1155Supply, ERC1155Metadata_URI, ERC1155
_burn
Burns _value tokens of token type _tokenId from _from.
Required override by Solidity.
Overrides _burn function of base contract and all extensions.
Deletes royalty info from storage, this is to avoid the need of a contract extension to override the _burn function in order to delete token royalty info.
supportsInterface
Checks if the contract supports a given interface.
Returns true if the contract supports the interface with the given ID, false otherwise.
Parameters
interfaceId
bytes4
The ID of the interface to check.
initialize
Initializes the contract.
Sets the symbol, _name, and default royalties, and grants roles.
Parameters
_data
bytes
The data to initialize the contract with.
setDefaultRoyalty
Sets the default royalty for the contract.
Can only be called by an account with the DEFAULT_ADMIN_ROLE.
Parameters
_receiver
address
The account to receive the royalty.
_feeNumerator
uint96
The numerator of the royalty fee.
setTokenRoyalty
Sets the royalty for a specific token.
Can only be called by an account with the DEFAULT_ADMIN_ROLE.
Parameters
_tokenId
uint256
The ID of the token to set the royalty for.
_receiver
address
The account to receive the royalty.
_feeNumerator
uint96
The numerator of the royalty fee.
setBaseURI
Sets the base URI for the contract.
Can only be called by an account with the DEFAULT_ADMIN_ROLE.
Parameters
baseURI_
string
The new base URI.
constructor
Creates DOMAIN_SEPARATOR and VOUCHER_TYPEHASH and assigns address to FACTORY.
factory_ is used for access control on self-sovereign ERC-1155 collection rather than using the initializer modifier, this is cheaper because the clones won't need to write initialized = true; to storage each time they are initialized. Instead FACTORY is only assigned once in the constructor of the master copy therefore it can be read by all clones.
Parameters
factory_
address
The factory address.
Last updated