Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Balance

Balance information from tzKT. For more information see the balance API documentation on tzKT.

Hierarchy

  • Balance

Index

Constructors

constructor

  • new Balance(balance: number, level: number, quote: null | BalanceShort, timestamp: Date): Balance

Properties

Readonly balance

balance: number

Readonly level

level: number

Readonly quote

quote: null | BalanceShort

Readonly timestamp

timestamp: Date

Methods

Static byDate

  • byDate(address: string, date: Date, domain?: string): Promise<number>
  • Fetches account balance at a given datetime from tzKT.

    see

    get balance at date.

    example

    Fetch balance at a given Date

    let address: string = 'tz1WEHHVMWxQUtkWAgrJBFGXjJ5YqZVgfPVE';
    let today: Date = new Date;
    let balance: number = Balance.byDate(address, today);
    

    Parameters

    • address: string
    • date: Date
    • domain: string = 'https://api.tzkt.io'

    Returns Promise<number>

    Returns account balance at the specified datetime

Static byLevel

  • byLevel(address: string, level: number, domain?: string): Promise<number>
  • Fetches balance history of an account from tzKT.

    see

    get balance history.

    example

    Fetch balance at a given block level

    let address: string = 'tz1WEHHVMWxQUtkWAgrJBFGXjJ5YqZVgfPVE';
    let level: number = 1500000;
    let balance: number = Balance.byLevel(address, level);
    

    Parameters

    • address: string
    • level: number
    • domain: string = 'https://api.tzkt.io'

    Returns Promise<number>

    time series with historical balances (only changes, without duplicates).

Static fromAPI

  • Converts data returned from API endpoints to Balance instances;

    internal

    Parameters

    • data: any

    Returns Balance

Static history

  • Fetches balance history of an account from tzKT.

    see

    get balance history.

    example

    Fetch balance history of an address

    Usage

    History by Date Range

    let address: string = 'tz1WEHHVMWxQUtkWAgrJBFGXjJ5YqZVgfPVE',
    steps: number = 100;
    let balanceHistory: Balance[] = await Balance.history(address, {'steps': steps});
    

    Parameters

    Returns Promise<Balance[]>

    time series with historical balances (only changes, without duplicates).

Static report

  • Exports account balance report in .csv format.

    see

    GetBalanceReport

    example

    Fetch balance report for an Address

    Usage

    Fetch Report by Date Range

    let address: string = 'tz1WEHHVMWxQUtkWAgrJBFGXjJ5YqZVgfPVE',
    fromDate: Date = new Date(2021, 0, 1),
    toDate: Date = new Date(2021, 5, 1),
    parameters: GetBalanceReportParameters = {'from': fromDate, 'to': toDate};
    let report: string = await Balance.report(address, parameters);
    

    Parameters

    Returns Promise<string>

    The account balance of the given account in csv format.

Generated using TypeDoc