Skip to main content

SignatureMint ERC1155

The SignatureMintERC1155 smart contract extension is meant to be used with any ERC1155 NFT smart contract.

The 'signature minting' mechanism in the SignatureMintERC1155 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/SignatureMintERC1155.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/ERC1155Base.sol";
import "@thirdweb-dev/contracts/extension/SignatureMintERC1155.sol";

contract MyNFT is ERC1155Base, SignatureMintERC1155 {
constructor(
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps
) ERC1155Base(_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 `SignatureMintERC1155` 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 `ERC1155Base`.
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 `SignatureMintERC1155` 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.