Skip to main content

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

metadata

Either provide a string that points to valid metadata object or an NFTMetadataInput object containing the metadata.

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

The image property can be an IPFS URI, a URL, or a File object.

If a file is provided for the image, it will also be uploaded and pinned to IPFS before minting.

Using a string:

# Option 1: Provide a string that points to valid metadata object
metadata = "https://example.com/metadata.json"

Using an object:

from thirdweb.types.nft import NFTMetadataInput
# Option 2: Provide a metadata object, which will be uploaded and pinned to IPFS for you.
metadata = 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
# ... Any other metadata you want to include
)

Provide the metadata to the mint function:

# Either the string or the object can be provided to the mint function
tx = contract.erc721.mint(metadata)

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

wallet_address

The address of the wallet you want to mint the NFT to.

from thirdweb.types.nft import NFTMetadataInput

wallet_address = "{{wallet_address}}"

metadata = NFTMetadataInput.from_json(
# ...
)

tx = contract.erc721.mint_to(wallet_address, metadata)

metadata

See metadata configuration above.

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

metadatas

A list of strings that point to, or NFTMetadataInput objects containing valid metadata properties.

List[Union(NFTMetadataInput, str)]

See mint for more details on the properties available.

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
),
])
Configuration

wallet_address

The address of the wallet you want to mint the NFTs to.

Must be a string.

metadatas

A list of strings that point to, or NFTMetadataInput objects containing valid metadata properties.

See mint for more details on the properties available.