LazyMint

import "@thirdweb-dev/contracts/extension/LazyMint.sol";

The LazyMint smart contract is an extension for any base NFT contract. It lets you 'lazy mint' any number of NFTs at once.

Here, 'lazy mint' means defining the metadata for particular tokenIds of your NFT contract, without actually minting a non-zero balance of NFTs of those tokenIds.


GitHub
View on GitHub

Usage

The LazyMint extension is an abstract contract, and expects you to implement the following functions by yourself:

NameTypeReturnsDescription
_canLazyMintinternal view virtualboolRuns on every attempt to lazy mint NFTs on the contract. Returns whether NFTs can be lazy minted in the given execution context.

This is an example smart contract demonstrating how to inherit from this extension and override the functions to add (optional) custom functionality.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@thirdweb-dev/contracts/extension/LazyMint.sol";
contract MyContract is LazyMint {
/**
* We store the contract deployer's address only for the purposes of the example
* in the code comment below.
*
* Doing this is not necessary to use the `LazyMint` extension.
*/
address public deployer;
constructor() {
deployer = msg.sender;
}
/**
* This function returns who is authorized to lazy mint NFTs on this contract.
*
* As an EXAMPLE, we'll only allow the contract deployer to lazy mint NFTs.
*
* You MUST complete the body of this function to use the `LazyMint` extension.
*/
function _canLazyMint() internal view virtual override returns (bool) {
return msg.sender == deployer;
}
}

Base Contracts Implementing This Extension

(if combined with either ERC721 or ERC1155)

Full API Reference