ERC20SignatureMintable
Functionality available for contracts that implement the
IERC20
and
ISignatureMintERC20
interfaces.
Allows you to utilize signature-based minting of new tokens.
generate
Generate a signature that a wallet address can use to mint the specified number of tokens.
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
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 signature = await contract.erc20.signature.generate(payload);
Configuration
generateBatch
Generate multiple signatures at once (see generate
).
const txResult = await contract.erc20.signature.generateBatch([
{
quantity: 100, // (Required) The quantity of tokens to be minted
to: "{{wallet_address}}", // (Required) Who will receive the tokens
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
},
{
quantity: 100, // (Required) The quantity of tokens to be minted
to: "{{wallet_address}}", // (Required) Who will receive the tokens
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
},
]);
Configuration
mint
Mint tokens from a previously generated signature (see generate
).
// Use the signed payload to mint the tokens
const txResult = contract.erc20.signature.mint(signature);
Configuration
mintBatch
Use multiple signatures at once to mint tokens.
Each signature must be of type SignedPayload20
.
const txResult = await contract.erc20.signature.mintBatch([
signature1, // Signature generated by the `generate` or `generateBatch` function
signature2,
signature3,
]);
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 (even without this verification check),
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.
const isValid = await contract.erc20.signature.verify(
signature, // A previously generated signature
);