Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Token

Index

Constructors

  • new Token(contractId: Uint8Array): Token
  • Create an instance of a token contract

    example
     const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    

    Parameters

    • contractId: Uint8Array

    Returns Token

Properties

_contractId: Uint8Array

Methods

  • balanceOf(owner: Uint8Array): number
  • Get the balance of the owner account

    example
     const ownerAccount = Base58.decode('1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqE');
    const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const balance = token.balanceOf(ownerAccount);

    Parameters

    • owner: Uint8Array

      owner account

    Returns number

    u64 balance

  • burn(from: Uint8Array, amount: number): bool
  • Burn tokens from from

    example
     const from = Base58.decode('1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe');
    const value = 12376182;

    const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const success = token.burn(from, value);
    if (success) {
    // transfer succeeded
    } else {
    // transfer failed
    }

    Parameters

    • from: Uint8Array

      from account

    • amount: number

    Returns bool

    bool burn succeeded or not

  • decimals(): number
  • Get the decimal of the token

    example
     const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const decimals = token.decimals();

    Returns number

    u32

  • mint(to: Uint8Array, amount: number): bool
  • Mint tokens to to account

    example
     const to = Base58.decode('1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqA');
    const value = 12376182;

    const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const success = token.mint(to, value);
    if (success) {
    // mint succeeded
    } else {
    // mint failed
    }

    Parameters

    • to: Uint8Array

      to account

    • amount: number

    Returns bool

    bool mint succeeded or not

  • name(): string
  • Get the name of the token

    example
     const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const name = token.name();

    Returns string

    string

  • symbol(): string
  • Get the symbol of the token

    example
     const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const symbol = token.symbol();

    Returns string

    string

  • totalSupply(): number
  • Get the total supply of the token

    example
     const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const totalSupply = token.totalSupply();

    Returns number

    u64

  • transfer(from: Uint8Array, to: Uint8Array, amount: number): bool
  • Transfer tokens from from to to

    example
     const from = Base58.decode('1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe');
    const to = Base58.decode('1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqE');
    const value = 12376182;

    const token = new Token(Base58.decode('1DQzuCcTKacbs9GGScFTU1Hc8BsyARTPqe'));
    const success = token.transfer(from, to, value);
    if (success) {
    // transfer succeeded
    } else {
    // transfer failed
    }

    Parameters

    • from: Uint8Array

      from account

    • to: Uint8Array

      to account

    • amount: number

    Returns bool

    bool transfer succeeded or not

Generated using TypeDoc