Class Erc20SignatureMintable

Enables generating ERC20 Tokens with rules and an associated signature, which can then be minted by anyone securely

Hierarchy

  • Erc20SignatureMintable

Implements

  • DetectableFeature

Constructors

Properties

contractWrapper: ContractWrapper<TokenERC20>
featureName: "ERC20SignatureMintable" = FEATURE_TOKEN_SIGNATURE_MINTABLE.name
mint: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Mint tokens from a signature

      Parameters

      Returns Promise<TResult>

      Remarks

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

      Example

      // 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);

      Twfeature

      ERC20SignatureMintable

  • prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>)
      • (...args): Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>
      • Parameters

        Returns Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>

mintBatch: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Mint any number of generated tokens signatures at once

      Parameters

      Returns Promise<TResult>

      Remarks

      Mint multiple token signatures in one transaction. Note that this is only possible for free mints (cannot batch mints with a price attached to it for security reasons)

      Twfeature

      ERC20SignatureMintable

  • prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>)
      • (...args): Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>
      • Parameters

        Returns Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>

roles: undefined | ContractRoles<TokenERC20, "transfer" | "minter" | "admin">

Methods

  • Generate a signature that can be used to mint a certain amount of tokens

    Parameters

    • mintRequest: {
          currencyAddress?: string;
          mintEndTime?: number | Date;
          mintStartTime?: number | Date;
          price?: string | number;
          primarySaleRecipient?: string;
          quantity: string | number;
          to: string;
          uid?: string;
      }

      the payload to sign

      • Optional currencyAddress?: string
      • Optional mintEndTime?: number | Date
      • Optional mintStartTime?: number | Date
      • Optional price?: string | number
      • Optional primarySaleRecipient?: string
      • quantity: string | number
      • to: string
      • Optional uid?: string

    Returns Promise<SignedPayload20>

    the signed payload and the corresponding signature

    Remarks

    Takes in a quantity of tokens, some conditions for how it can be minted and signs it with your private key. The generated signature can then be used to mint those tokens using the exact payload and signature generated.

    Example

    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)`

    Twfeature

    ERC20SignatureMintable

  • Generate a batch of signatures that can be used to mint many token signatures.

    Parameters

    • payloadsToSign: {
          currencyAddress?: string;
          mintEndTime?: number | Date;
          mintStartTime?: number | Date;
          price?: string | number;
          primarySaleRecipient?: string;
          quantity: string | number;
          to: string;
          uid?: string;
      }[]

      the payloads to sign

    Returns Promise<SignedPayload20[]>

    an array of payloads and signatures

    Remarks

    See Erc20SignatureMintable.generate

    Twfeature

    ERC20SignatureMintable

  • Verify that a payload is correctly signed

    Parameters

    Returns Promise<boolean>

    Twfeature

    ERC20SignatureMintable

    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 you can verify if the signed payload is valid
    const isValid = await contract.erc20.signature.verify(signedPayload);

Generated using TypeDoc