Erc1155SignatureMintable
Enables generating dynamic ERC1155 NFTs with rules and an associated signature, which can then be minted by anyone securely
class Erc1155SignatureMintable implements DetectableFeature {}
function constructor( contractWrapper: ContractWrapper< BaseSignatureMintERC1155 | TokenERC1155 >, TokenERC1155, "metadata" | "transfer" | "minter" | "admin" >,
TokenERC1155, "metadata" | "transfer" | "minter" | "admin">;
Generate a signature that can be used to mint an NFT dynamically.
Takes in an NFT and some information about how it can be minted, uploads the metadata and signs it with your private key. The generated signature can then be used to mint an NFT using the exact payload and signature generated.
const nftMetadata = { name: "Cool NFT #1", description: "This is a cool NFT", image: fs.readFileSync("path/to/image.png"), // This can be an image url or file}; const startTime = new Date();const endTime = new Date(Date.now() + 60 * 60 * 24 * 1000);const payload = { metadata: nftMetadata, // The NFT to mint to: {{wallet_address}}, // Who will receive the NFT quantity: 2, // the quantity of NFTs to mint price: 0.5, // the price per NFT currencyAddress: NATIVE_TOKEN_ADDRESS, // the currency to pay with mintStartTime: startTime, // can mint anytime from now mintEndTime: endTime, // to 24h from now royaltyRecipient: "0x...", // custom royalty recipient for this NFT royaltyBps: 100, // custom royalty fees for this NFT (in bps) primarySaleRecipient: "0x...", // custom sale recipient for this NFT}; const signedPayload = await contract.erc1155.signature.generate(payload);// now anyone can use these to mint the NFT using `contract.erc1155.signature.mint(signedPayload)`
function generate(payloadToSign: { currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<ZodString, string, string>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }) : Promise<SignedPayload1155>
the payload to sign
let payloadToSign: { currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<ZodString, string, string>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }
The signed payload and the corresponding signature
Generate a batch of signatures that can be used to mint many new NFTs dynamically.
See Erc1155SignatureMintable.generate
function generateBatch(payloadsToSign: Array<{ currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<...>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<..., ..., ...>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }>) : Promise<Array<SignedPayload1155>>
the payloads to sign
let payloadsToSign: Array<{ currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<...>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<..., ..., ...>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; uid?: string }>
An array of payloads and signatures
Generate a batch of signatures that can be used to mint new NFTs or additionally supply to existing NFTs dynamically.
See Erc1155SignatureMintable.generateFromTokenId
function generateBatchFromTokenIds(payloadsToSign: Array<{ currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<...>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<..., ..., ...>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; tokenId: string | number | bigint | (BigNumber); uid?: string }>) : Promise<Array<SignedPayload1155>>
the payloads to sign with tokenIds specified
let payloadsToSign: Array<{ currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<...>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<..., ..., ...>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<...>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<..., ..., ...>, ZodArray<..., ...>, ZodObject<..., ..., ..., ..., ...>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; tokenId: string | number | bigint | (BigNumber); uid?: string }>
An array of payloads and signatures
Generate a signature that can be used to mint additionally supply to an existing NFT.
Takes in a payload with the token ID of an existing NFT, and signs it with your private key. The generated signature can then be used to mint additional supply to the NFT using the exact payload and signature generated.
const nftMetadata = { name: "Cool NFT #1", description: "This is a cool NFT", image: fs.readFileSync("path/to/image.png"), // This can be an image url or file}; const startTime = new Date();const endTime = new Date(Date.now() + 60 * 60 * 24 * 1000);const payload = { tokenId: 0, // Instead of metadata, we specify the token ID of the NFT to mint supply to to: {{wallet_address}}, // Who will receive the NFT (or AddressZero for anyone) quantity: 2, // the quantity of NFTs to mint price: 0.5, // the price per NFT currencyAddress: NATIVE_TOKEN_ADDRESS, // the currency to pay with mintStartTime: startTime, // can mint anytime from now mintEndTime: endTime, // to 24h from now royaltyRecipient: "0x...", // custom royalty recipient for this NFT royaltyBps: 100, // custom royalty fees for this NFT (in bps) primarySaleRecipient: "0x...", // custom sale recipient for this NFT}; const signedPayload = await contract.erc1155.signature.generateFromTokenId(payload);// now anyone can use these to mint the NFT using `contract.erc1155.signature.mint(signedPayload)`
function generateFromTokenId(payloadToSign: { currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<ZodString, string, string>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; tokenId: string | number | bigint | (BigNumber); uid?: string }) : Promise<SignedPayload1155>
the payload to sign
let payloadToSign: { currencyAddress?: string; metadata?: string | (objectInputType<extendShape<{ animation_url: ZodNullable<ZodOptional<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; description: ZodNullable<ZodOptional<ZodNullable<ZodString>>>; image: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; name: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodNumber]>>> }, { attributes: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>>; background_color: ZodNullable<ZodOptional<ZodUnion<[ZodString, ZodEffects<ZodString, string, string>, ZodString]>>>; external_url: ZodOptional<ZodNullable<ZodUnion<[ZodUnion<[..., ...]>, ZodString]>>>; properties: ZodNullable<ZodOptional<ZodUnion<[ZodEffects<ZodArray<..., ...>, Array<...>, Array<...>>, ZodArray<ZodObject<..., ..., ..., ..., ...>, "many">, ZodObject<{ }, "strip", ZodUnion<...>, objectOutputType<..., ..., ...>, objectInputType<..., ..., ...>>]>>> }>, ZodUnion<[ZodEffects<ZodUnion<[ZodBigInt, ZodType<BigNumber, ZodTypeDef, BigNumber>, ZodType<BN, ZodTypeDef, BN>]>, string, bigint | (BN) | (BigNumber)>, ZodUnknown]>, "strip">); mintEndTime?: number | (Date); mintStartTime?: number | (Date); price?: string | number; primarySaleRecipient?: string; quantity: string | number | bigint | (BigNumber); royaltyBps?: number; royaltyRecipient?: string; to: string; tokenId: string | number | bigint | (BigNumber); uid?: string }
The signed payload and the corresponding signature
Verify that a payload is correctly signed
const nftMetadata = { name: "Cool NFT #1", description: "This is a cool NFT", image: fs.readFileSync("path/to/image.png"), // This can be an image url or file}; const startTime = new Date();const endTime = new Date(Date.now() + 60 * 60 * 24 * 1000);const payload = { metadata: nftMetadata, // The NFT to mint to: {{wallet_address}}, // Who will receive the NFT quantity: 2, // the quantity of NFTs to mint price: 0.5, // the price per NFT currencyAddress: NATIVE_TOKEN_ADDRESS, // the currency to pay with mintStartTime: startTime, // can mint anytime from now mintEndTime: endTime, // to 24h from now royaltyRecipient: "0x...", // custom royalty recipient for this NFT royaltyBps: 100, // custom royalty fees for this NFT (in bps) primarySaleRecipient: "0x...", // custom sale recipient for this NFT}; const signedPayload = contract.erc1155.signature.generate(payload);// Now you can verify that the payload is validconst isValid = await contract.erc1155.signature.verify(signedPayload);
Preparable
You can also prepare the transaction without executing it by calling mint.prepare()
with same arguments.Learn more
function mintBatch(): Promise<TResult>;
Preparable
You can also prepare the transaction without executing it by calling mintBatch.prepare()
with same arguments.Learn more
let featureName: "ERC1155SignatureMintable";