ERC1155LazyMint
The ERC1155LazyMint smart contract allows creators to lazy-mint ERC-1155 tokens. Lazy minting allows you to define the metadata of tokens without minting them to an address. As a contract admin, this lets you prepare the metadata for tokens that will be minted by other wallets, without paying the gas cost for actually minting the tokens.
Usage
import "@ninfa-labs/contracts/token/ERC1155/presets/ERC1155LazyMint.sol";This contract preset is itself inheriting from ERC1155Base and extends it with the required functionality for lazy minting. It is not meant to be imported but rather used as standalone. All the extensions used by ERC1155Base are therefore inherited by ERC1155LazyMint as well and can be accessed or overridden by this implementation.
For example, the initialize function of the base contract is overridden in order to add the EIP712 extension. This is a required override since both contracts have the same function interface:
contract ERC1155LazyMint is ERC1155Base, EIP712 {
function initialize(bytes memory _data) public override(ERC1155Base, EIP712) {
ERC1155Base.initialize(_data);
// initialize Base contract before EIP712 because
// "name" metadata MUST to be set prior calling EIP712's initialize()
EIP712.initialize("");
}
constructor(address factory_) ERC1155Base(factory_) { }
}Features
Lazy Minting: Allows the creation of token metadata without the immediate minting of the token. This allows for the preparation of tokens to be minted by other wallets without incurring the gas cost of minting.
EIP712 Integration: The
EIP712standard is used for structuring data to be signed by an Ethereum wallet. This provides a secure and standard way to verify the identity of transactions and data on the Ethereum blockchain.Minting and Buying: The contract includes functions for both minting new tokens (
lazyMint) and buying existing tokens (lazyBuy). These functions handle the necessary checks and operations for each process.Payment Handling: The
_handlePaymentfunction is used to handle the payment process for both minting and buying operations. This includes the calculation and distribution of royalties.Access Control: The contract uses the
AccessControlextension for role-based access control. This allows for the restriction of certain operations to specific roles, such as theMINTER_ROLE.Royalty Tracking: The contract tracks both royalties and token market (primary and secondary) using the ERC-2981 royalty standard.
Last updated