ERC1155SignatureMintable
Functionality available for contracts that implement the
IERC1155
and
ISignatureMintERC1155
interfaces.
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.
const payload = {
quantity: 100, // (Required) The quantity of tokens to be minted
to: "{{wallet_address}}", // (Required) Who will receive the tokens
metadata: {
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
},
currencyAddress: "{{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)
mintStartTime: new Date(), // (Optional) can mint anytime from now
mintEndTime: new Date(Date.now() + 60 * 60 * 24 * 1000), // (Optional) to 24h from now,
primarySaleRecipient: "0x...", // (Optional) custom sale recipient for this token mint
};
const signedPayload = contract.erc1155.signature.generate(payload);
Configuration
generateBatch
Generate a batch of signatures at once.
This is the same as generate
but it allows you to generate multiple signatures at once.
const signatures = await contract.erc1155.signature.generateBatch([
{
to: "{{wallet_address}}",
quantity: "{{quantity}}",
metadata: {
// ... Your NFT metadata
},
}
{
to: "{{wallet_address}}",
quantity: "{{quantity}}",
metadata: {
// ... Your NFT metadata
},
}
]);
Configuration
generateFromTokenId
Generate a signature that can be used to mint additional supply of an existing NFT in the contract.
This is the same as generate
but it allows you to specify the tokenId
of the NFT you want to mint additional supply for, rather than
providing the metadata
of the NFT. Each other configuration option is the same as generate
.
const signature = await contract.erc1155.signature.generateFromTokenId({
to: "{{wallet_address}}",
tokenId: "{{token_id}}",
quantity: "{{quantity}}",
});
Configuration
generateBatchFromTokenIds
Generate a batch of signatures that can be used to mint additional supply of existing NFTs in the contract.
This is the same as generateBatch
but allows you to generate multiple signatures at once.
const signatures = await contract.erc1155.signature.generateBatchFromTokenIds([
{
to: "{{wallet_address}}",
tokenId: "{{token_id}}",
quantity: "{{quantity}}",
},
{
to: "{{wallet_address}}",
tokenId: "{{token_id}}",
quantity: "{{quantity}}",
},
]);
Configuration
mint
Mint tokens from a previously generated signature (see generate
).
// Use the signed payload to mint the tokens
const txResult = contract.erc1155.signature.mint(signature);
Configuration
mintBatch
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
const txResult = contract.erc1155.signature.mintBatch(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
/mintBatch
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
const isValid = await contract.erc1155.signature.verify(payload);