Signature-based Minting
Functionality available for contracts that implement the
ERC721
and
ERC721SignatureMint
extensions.
Allows you to utilize signature-based minting of NFTs.
generate
Generate a signature that a wallet address can use to mint the specified number of NFTs.
This is typically an admin operation, where the owner of the contract generates a signature that allows another wallet to mint tokens.
from thirdweb.types.nft import NFTMetadataInput
from thirdweb.types.contracts.signature import PayloadToSign721
payload_to_sign = PayloadToSign721(
to = "{{wallet_address}}", # (Required) Who will receive the tokens
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
),
currency_address = "{{currency_contract_address}}", # (Optional) the currency to pay with
price = 0.5, # (Optional) the price to pay for minting those tokens (in the currency above)
mint_start_time = int(time()), # (Optional) can mint anytime from now
mint_end_time = int(time() + 60 * 60 * 24 * 1000), # (Optional) to 24h from now,
primary_sale_recipient = "0x...", # (Optional) custom sale recipient for this token mint
quantity = 100, # (Optional) The quantity of tokens to be minted
)
signed_payload = contract.erc721.signature.generate(payload)
Configuration
generate_batch
Generate a batch of signatures at once.
This is the same as generate
but it allows you to generate multiple signatures at once.
from thirdweb.types.nft import NFTMetadataInput
from thirdweb.types.contracts.signature import PayloadToSign721
signatures = contract.erc721.signature.generateBatch([
PayloadToSign721(
to = "{{wallet_address}}",
metadata = NFTMetadataInput.from_json(
# ... Your NFT metadata
),
)
PayloadToSign721(
to = "{{wallet_address}}",
metadata = NFTMetadataInput.from_json(
# ... Your NFT metadata
),
)
])
Configuration
mint
Mint tokens from a previously generated signature (see generate
).
# Use the signed payload to mint the tokens
tx = contract.erc721.signature.mint(signature)
Configuration
mint_batch
Use multiple signatures at once to mint tokens.
This is the same as mint
but it allows you to provide multiple signatures at once.
# Use the signed payloads to mint the tokens
tx = contract.erc721.signature.mint_batch(signatures)
Configuration
verify
Verify that a payload is correctly signed.
This allows you to provide a payload, and prove that it was valid and was generated by a wallet with permission to generate signatures.
If a payload is not valid, the mint
/mint_batch
functions will fail,
but you can use this function to verify that the payload is valid before attempting to mint the tokens
if you want to show a more user-friendly error message.
# Provide the generated payload to verify that it is valid
is_valid = contract.erc721.signature.verify(payload)