Class StandardErc20<T>

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.token.transfer(walletAddress, amount);

Type Parameters

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

Hierarchy

Implements

  • UpdateableNetwork

Constructors

Properties

_chainId: number
contractWrapper: ContractWrapper<T>
erc20: Erc20<T>
setAllowance: {
    prepare: ((...args) => Promise<Transaction<Omit<TransactionResultWithMetadata<unknown>, "data">>>);
    (...args): Promise<TResult>;
} = ...

Type declaration

    • (...args): Promise<TResult>
    • Allows the specified spender wallet to transfer the given amount of tokens to another wallet

      Parameters

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

      Returns Promise<TResult>

      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.setAllowance(spenderAddress, amount);
  • 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">>>

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.transfer(toAddress, amount);
  • 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.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 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.transferFrom(fromAddress, toAddress, amount);
  • 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

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.allowance(spenderAddress);
  • Get Token Allowance

    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.allowanceOf(owner, spender);
  • 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.balance();
    
  • Get Token Balance

    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

    // Address of the wallet to check token balance
    const walletAddress = "{{wallet_address}}";
    const balance = await contract.balanceOf(walletAddress);
  • Get the token Metadata (name, symbol, etc...)

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

    The token metadata

    Example

    const token = await contract.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.totalSupply();
    

Generated using TypeDoc