Skip to main content

SignatureMint ERC721

The SignatureMintERC721 smart contract extension is meant to be used with any ERC721 NFT smart contract.

The 'signature minting' mechanism in the SignatureMintERC721 extension uses EIP 712, and is a way for a contract admin to authorize an external party's request to mint tokens on the admin's contract.

At a high level, this means you can authorize some external party to mint tokens on your contract, and specify what exactly will be minted by that external party.

Import

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

Available functionality

FunctionalityDescription
mintWithSignatureMints tokens according to a given mint request, signed off i.e. approved by an authorized wallet.
_canSignMintRequestDefines the criteria a wallet must meet to be able to sign off on mint requests.

Implementing the Contract extension.

Import the contract extension and make your contract inherit it.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@thirdweb-dev/contracts/base/ERC721Base.sol";
import "@thirdweb-dev/contracts/extension/SignatureMintERC721.sol";

contract MyNFT is ERC721Base, SignatureMintERC721 {
constructor(
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps
) ERC721Base(_name, _symbol, _royaltyRecipient, _royaltyBps) {}

/**
* @notice Mints tokens according to the provided mint request.
*
* @param _req The mint request.
* @param _signature The signature produced by an account signing the mint request.
*
* You MUST complete the body of this function to use the `SignatureMintERC721` extension.
*/
function mintWithSignature(
MintRequest calldata _req,
bytes calldata _signature
) external payable virtual override returns (address signer) {
require(_req.quantity > 0, "Minting zero tokens.");

// Verify and process payload.
signer = _processRequest(_req, _signature);

// Mint tokens according to the mint request via `mintTo` made available by `ERC721Base`.
mintTo(_req.to, _req.uri);
}

/**
* This function returns who is authorized to sign off on mint requests.
*
* As an EXAMPLE, we'll only allow the contract's current owner to sign off on mint requests.
*
* You MUST complete the body of this function to use the `SignatureMintERC721` extension.
*/
function _canSignMintRequest(address _signer)
internal
view
virtual
override
returns (bool)
{
return _signer == owner();
}
}

Unlocked Features

From the SDK you'll now be able to generate mint signatures and mint tokens with them.