Skip to main content

Lazy Mint

Functionality available for contracts that implement the ERC1155 and LazyMint extensions.

create_batch

Lazy mint a new batch of NFTs into the smart contract.

By default, the NFT metadata is uploaded and pinned to IPFS before minting. You can override this default behavior by providing a string that points to valid metadata instead of objects.

The metadata must conform to the metadata standards.

from thirdweb.types.nft import NFTMetadataInput, EditionMetadataInput

# Note that you can customize this metadata however you like
metadatas = [
EditionMetadataInput(
NFTMetadataInput.from_json({
"name": "Cool NFT",
"description": "This is a cool NFT",
"image": open("path/to/file.jpg", "rb"),
}),
100
),
EditionMetadataInput(
NFTMetadataInput.from_json({
"name": "Cooler NFT",
"description": "This is a cooler NFT",
"image": open("path/to/file.jpg", "rb"),
}),
100
)
]

txs = contract.erc1155.create_batch(metadatas)
first_token_id = txs[0].id
first_nft = txs[0].data()

Alternatively, you can provide a string that points to valid metadata instead of objects.

from thirdweb.types.nft import EditionMetadataInput

supply = 1
metadata_one = EditionMetadataInput("ipfs://Qm...", supply) # IPFS URI
metadata_two = EditionMetadataInput("https://my-nft-metadata.json", supply) # Some other URL

txs = contract.erc1155.create_batch([metadata_one, metadata_two])
Configuration

metadatas

The metadatas must be of type List[EditionMetadataInput]

class EditionMetadataInput:
metadata: Union[NFTMetadataInput, str]
supply: int

For each EditionMetadataInput object provide the following:

  • The supply, of type int
  • Either a string that point to valid metadata properties, or NFTMetadataInput objects that contain the following information:
class NFTMetadataInput:
name: str
description: Optional[str] = None
image: Optional[str] = None
external_url: Optional[str] = None
animation_url: Optional[str] = None
background_color: Optional[str] = None
properties: Optional[Dict[str, Any]] = None
attributes: Optional[Dict[str, Any]] = None