Standard ERC20 Token functions

Remarks

Basic functionality for a ERC20 contract that handles all unit transformation for you.

Example

const contract = await sdk.getContract("{{contract_address}}");
await contract.erc20.transfer(walletAddress, amount);

Type Parameters

  • T extends TokenERC20 | DropERC20 | BaseERC20 = BaseERC20 | BaseSignatureMintERC20

Hierarchy

  • Erc20

Implements

  • UpdateableNetwork
  • DetectableFeature

Constructors

  • Type Parameters

    • T extends BaseERC20 | DropERC20 | TokenERC20 = BaseERC20 | BaseSignatureMintERC20

    Parameters

    • contractWrapper: ContractWrapper<T>
    • storage: ThirdwebStorage<IpfsUploadBatchOptions>
    • chainId: number

    Returns Erc20<T>

Properties

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

Type declaration

    • (...args): Promise<TResult>
    • Burn tokens

      Parameters

      • Rest ...args: [amount: string | number]

      Returns Promise<TResult>

      Remarks

      Burn tokens held by the connected wallet

      Example

      // The amount of this token you want to burn
      const amount = 1.2;

      await contract.erc20.burn(amount);

      Twfeature

      ERC20Burnable

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

        • Rest ...args: [amount: string | number]

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

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

Type declaration

    • (...args): Promise<TResult>
    • Burn tokens from a specific wallet

      Parameters

      • Rest ...args: [holder: string, amount: string | number]

      Returns Promise<TResult>

      Remarks

      Burn tokens held by the specified wallet

      Example

      // Address of the wallet sending the tokens
      const holderAddress = "{{wallet_address}}";

      // The amount of this token you want to burn
      const amount = 1.2;

      await contract.erc20.burnFrom(holderAddress, amount);

      Twfeature

      ERC20Burnable

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

        • Rest ...args: [holder: string, amount: string | number]

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

burnable: undefined | Erc20Burnable
claim: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Claim tokens

      Parameters

      • Rest ...args: [amount: string | number, options?: ClaimOptions]

      Returns Promise<TResult>

      • The transaction receipt

      Remarks

      Let the specified wallet claim Tokens.

      Example

      const address = "{{wallet_address}}"; // address of the wallet you want to claim the NFTs
      const quantity = 42.69; // how many tokens you want to claim

      const tx = await contract.erc20.claim(address, quantity);
      const receipt = tx.receipt; // the transaction receipt

      Twfeature

      ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1

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

        • Rest ...args: [amount: string | number, options?: ClaimOptions]

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

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

Type declaration

    • (...args): Promise<TResult>
    • Claim tokens to a specific wallet

      Parameters

      • Rest ...args: [destinationAddress: string, amount: string | number, options?: ClaimOptions]

      Returns Promise<TResult>

      • The transaction receipt

      Remarks

      Let the specified wallet claim Tokens.

      Example

      const address = "{{wallet_address}}"; // address of the wallet you want to claim the NFTs
      const quantity = 42.69; // how many tokens you want to claim

      const tx = await contract.erc20.claim(address, quantity);
      const receipt = tx.receipt; // the transaction receipt

      Twfeature

      ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1

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

        • Rest ...args: [destinationAddress: string, amount: string | number, options?: ClaimOptions]

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

contractWrapper: ContractWrapper<T>
droppable: undefined | Erc20Droppable
featureName: "ERC20" = FEATURE_TOKEN.name
mint: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

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

      Parameters

      • Rest ...args: [amount: string | number]

      Returns Promise<TResult>

      Remarks

      Mint tokens to the connected wallet.

      Example

      const amount = "1.5"; // The amount of this token you want to mint
      await contract.erc20.mint(amount);

      Twfeature

      ERC20Mintable

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

        • Rest ...args: [amount: string | number]

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

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

Type declaration

    • (...args): Promise<TResult>
    • Mint tokens to many wallets

      Parameters

      • Rest ...args: [args: {
            amount: string | number;
            toAddress: string;
        }[]]

      Returns Promise<TResult>

      Remarks

      Mint tokens to many wallets in one transaction.

      Example

      // Data of the tokens you want to mint
      const data = [
      {
      toAddress: "{{wallet_address}}", // Address to mint tokens to
      amount: 0.2, // How many tokens to mint to specified address
      },
      {
      toAddress: "0x...",
      amount: 1.4,
      }
      ]

      await contract.mintBatchTo(data);

      Twfeature

      ERC20BatchMintable

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

        • Rest ...args: [args: {
              amount: string | number;
              toAddress: string;
          }[]]

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

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

Type declaration

    • (...args): Promise<TResult>
    • Mint tokens to a specific wallet

      Parameters

      • Rest ...args: [receiver: string, amount: string | number]

      Returns Promise<TResult>

      Remarks

      Mint tokens to a specified address.

      Example

      const toAddress = "{{wallet_address}}"; // Address of the wallet you want to mint the tokens to
      const amount = "1.5"; // The amount of this token you want to mint
      await contract.erc20.mintTo(toAddress, amount);

      Twfeature

      ERC20Mintable

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

        • Rest ...args: [receiver: string, amount: string | number]

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

mintable: undefined | Erc20Mintable

Mint tokens

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

Type declaration

    • (...args): Promise<TResult>
    • Set token allowance

      Parameters

      • Rest ...args: [spender: string, amount: string | number]

      Returns Promise<TResult>

      Remarks

      Allows the specified spender wallet to transfer the given amount of tokens to another wallet

      Example

      // Address of the wallet to allow transfers from
      const spenderAddress = "0x...";
      // The number of tokens to give as allowance
      const amount = 100
      await contract.erc20.setAllowance(spenderAddress, amount);

      Twfeature

      ERC20

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

        • Rest ...args: [spender: string, amount: string | number]

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

signatureMintable: undefined | Erc20SignatureMintable
storage: ThirdwebStorage<IpfsUploadBatchOptions>
transfer: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Transfer tokens

      Parameters

      • Rest ...args: [to: string, amount: string | number]

      Returns Promise<TResult>

      Remarks

      Transfer tokens from the connected wallet to another wallet.

      Example

      // Address of the wallet you want to send the tokens to
      const toAddress = "0x...";
      // The amount of tokens you want to send
      const amount = 0.1;
      await contract.erc20.transfer(toAddress, amount);

      Twfeature

      ERC20

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

        • Rest ...args: [to: string, amount: string | number]

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

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

Type declaration

    • (...args): Promise<TResult>
    • Transfer tokens to many wallets

      Parameters

      • Rest ...args: [args: {
            amount: string | number;
            toAddress: string;
        }[]]

      Returns Promise<TResult>

      Remarks

      Mint tokens from the connected wallet to many wallets

      Example

      // Data of the tokens you want to mint
      const data = [
      {
      toAddress: "{{wallet_address}}", // Address to mint tokens to
      amount: 100, // How many tokens to mint to specified address
      },
      {
      toAddress: "0x...",
      amount: 100,
      }
      ]

      await contract.erc20.transferBatch(data);
  • prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>)
      • (...args): Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>
      • Parameters

        • Rest ...args: [args: {
              amount: string | number;
              toAddress: string;
          }[]]

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

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

Type declaration

    • (...args): Promise<TResult>
    • Transfer tokens from a specific address

      Parameters

      • Rest ...args: [from: string, to: string, amount: string | number]

      Returns Promise<TResult>

      Remarks

      Transfer tokens from one wallet to another

      Example

      // Address of the wallet sending the tokens
      const fromAddress = "{{wallet_address}}";
      // Address of the wallet you want to send the tokens to
      const toAddress = "0x...";
      // The number of tokens you want to send
      const amount = 1.2
      // Note that the connected wallet must have approval to transfer the tokens of the fromAddress
      await contract.erc20.transferFrom(fromAddress, toAddress, amount);

      Twfeature

      ERC20

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

        • Rest ...args: [from: string, to: string, amount: string | number]

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

Accessors

  • get claimConditions(): DropClaimConditions<BaseDropERC20>
  • Configure claim conditions

    Returns DropClaimConditions<BaseDropERC20>

    Remarks

    Define who can claim NFTs in the collection, when and how many.

    Example

    const presaleStartTime = new Date();
    const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
    const claimConditions = [
    {
    startTime: presaleStartTime, // start the presale now
    maxClaimableSupply: 2, // limit how many mints for this presale
    price: 0.01, // presale price
    snapshot: ['0x...', '0x...'], // limit minting to only certain addresses
    },
    {
    startTime: publicSaleStartTime, // 24h after presale, start public sale
    price: 0.08, // public sale price
    }
    ]);
    await contract.erc20.claimConditions.set(claimConditions);

    Twfeature

    ERC20ClaimPhasesV2 | ERC20ClaimPhasesV1 | ERC20ClaimConditionsV2 | ERC20ClaimConditionsV1

  • get signature(): Erc20SignatureMintable
  • Mint with signature

    Returns Erc20SignatureMintable

    Remarks

    Generate dynamic tokens with your own signature, and let others mint them using that signature.

    Example

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

    // now the payload can be used to mint tokens
    const tx = contract.erc20.signature.mint(signedPayload);

    Twfeature

    ERC20SignatureMintable

Methods

  • Get token allowance

    Parameters

    • spender: string

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    The allowance of one wallet over anothers funds.

    Remarks

    Get the allowance of a 'spender' wallet over the connected wallet's funds - the allowance of a different address for a token is the amount of tokens that the spender wallet is allowed to spend on behalf of the connected wallet.

    Example

    // Address of the wallet to check token allowance
    const spenderAddress = "0x...";
    const allowance = await contract.erc20.allowance(spenderAddress);

    Twfeature

    ERC20

  • Get token allowance of a specific wallet

    Parameters

    • owner: string
    • spender: string

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    The allowance of one wallet over anothers funds.

    Remarks

    Get the allowance of one wallet over another wallet's funds - the allowance of a different address for a token is the amount of tokens that the wallet is allowed to spend on behalf of the specified wallet.

    Example

    // Address of the wallet who owns the funds
    const owner = "{{wallet_address}}";
    // Address of the wallet to check token allowance
    const spender = "0x...";
    const allowance = await contract.erc20.allowanceOf(owner, spender);

    Twfeature

    ERC20

  • Get token balance for the currently connected wallet

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    The balance of a specific wallet.

    Remarks

    Get a wallets token balance.

    Example

    const balance = await contract.erc20.balance();
    

    Twfeature

    ERC20

  • Get token balance for a specific wallet

    Parameters

    • address: string

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    The balance of a specific wallet.

    Remarks

    Get a wallets token balance.

    Example

    const walletAddress = "{{wallet_address}}";
    const balance = await contract.erc20.balanceOf(walletAddress);

    Twfeature

    ERC20

  • Get the token metadata

    Returns Promise<{
        decimals: number;
        name: string;
        symbol: string;
    }>

    The token metadata

    Remarks

    name, symbol, etc...

    Example

    const token = await contract.erc20.get();
    

    Twfeature

    ERC20

  • Construct a mint transaction without executing it

    Parameters

    • receiver: string

      Address you want to send the token to

    • amount: string | number

      The amount of tokens you want to mint

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

    Remarks

    This is useful for estimating the gas cost of a mint transaction, overriding transaction options and having fine grained control over the transaction execution.

    Deprecated

    Use contract.erc20.mint.prepare(...args) instead

    Twfeature

    ERC20Mintable

  • Get the total supply for this token

    Returns Promise<{
        decimals: number;
        displayValue: string;
        name: string;
        symbol: string;
        value: BigNumber;
    }>

    Remarks

    Get how much supply has been minted

    Example

    const balance = await contract.erc20.totalSupply();
    

    Twfeature

    ERC20

Generated using TypeDoc