ERC721Mintable
Functionality available for contracts that implement the
ERC721
and
ERC721Mintable
interfaces.
Allows you to mint new NFTs on the 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 object instead of an object.
mint
Mint a new NFT to the connected wallet.
from thirdweb.types.nft import NFTMetadataInput
# You can customize the metadata to your needs
metadata = NFTMetadataInput.from_json({
"name": "Cool NFT",
"description": "This is a cool NFT",
"image": open("path/to/file.jpg", "rb")
})
tx = contract.erc721.mint(metadata)
receipt = tx.receipt
token_id = tx.id
nft = tx.data()
Configuration
mint_to
The same as mint
, but allows you to specify the address of the wallet that will receive the NFT rather than using
the connected wallet address.
from thirdweb.types.nft import NFTMetadataInput
# Note that you can customize this metadata however you like
metadata = NFTMetadataInput.from_json({
"name": "Cool NFT",
"description": "This is a cool NFT",
"image": open("path/to/file.jpg", "rb"),
})
# You can pass in any address here to mint the NFT to
tx = contract.erc721.mint_to("0x7fDae677aA6f94Edff9872C4b91D26407709c790", metadata)
receipt = tx.receipt
token_id = tx.id
nft = tx.data()
Configuration
mint_batch
Mint multiple NFTs in a single transaction to the connected wallet.
from thirdweb.types.nft import NFTMetadataInput
tx = contract.erc721.mint_batch([
NFTMetadataInput.from_json(
"name": "Cool NFT #1",
"description": "This is a cool NFT",
"image": "https://example.com/image.png", // URL, IPFS URI, or File object
),
NFTMetadataInput.from_json(
"name": "Cool NFT #2",
"description": "This is a cool NFT",
"image": "https://example.com/image.png", // URL, IPFS URI, or File object
),
])
Configuration
mint_batch_to
The same as mint_batch
, but allows you to specify the address
of the wallet that will receive the NFTs rather than using the connected wallet address.
from thirdweb.types.nft import NFTMetadataInput
tx = contract.erc721.mint_batch_to("{{wallet_address}}", [
NFTMetadataInput.from_json(
"name": "Cool NFT #1",
"description": "This is a cool NFT",
"image": "https://example.com/image.png", // URL, IPFS URI, or File object
),
NFTMetadataInput.from_json(
"name": "Cool NFT #2",
"description": "This is a cool NFT",
"image": "https://example.com/image.png", // URL, IPFS URI, or File object
),
])