Skip to main content

ERC20 - Signature-Based Minting

You can utilize these features of the SDK on your contract if it implements SignatureMintERC20.

Generate a signature

Generate a signature that can be utilized to mint tokens by another wallet.

The signature specifies any information about the tokens such as the price and currency.

Admin Operation

The generation of signatures requires the wallet to have the MINTER role on the contract by default.

const startTime = new Date();
const endTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
const payload = {
quantity: 4.2, // The quantity of tokens to be minted
to: {{wallet_address}}, // Who will receive the tokens
price: 0.5, // the price to pay for minting those tokens
currencyAddress: NATIVE_TOKEN_ADDRESS, // the currency to pay with
mintStartTime: startTime, // can mint anytime from now
mintEndTime: endTime, // to 24h from now,
primarySaleRecipient: "0x...", // custom sale recipient for this token mint
};

const signedPayload = await contract.erc20.signature.generate(payload);
// now anyone can use these to mint the NFT using `contract.erc20.signature.mint(signedPayload)`

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation

Use a signature to mint tokens

Mint a certain amount of tokens from a previously generated signature.

// see how to craft a payload to sign in the `generate()` documentation
const signedPayload = contract.erc20.signature.generate(payload);

// Use the signed payload to mint the tokens
const tx = contract.erc20.signature.mint(signedPayload);

This snippet is for v3 of the SDK. Learn how to upgrade.

View in React SDK Documentation