Module for handling account-related operations on Conflux eSpace. Provides methods for querying account balances, transactions, token transfers, and other account data.

AccountModule

Hierarchy (View Summary)

Constructors

Properties

baseUrl: string

Base URL for the API endpoints

apiKey?: string

Optional API key for authenticated requests

logger: Logger<never> = ...

Logger instance for account operations

Methods

  • Protected

    Makes an API request with the given parameters. Handles parameter sanitization, API key inclusion, and error handling.

    Type Parameters

    • T

      Type of the expected response data

    Parameters

    • endpoint: string

      API endpoint to call

    • params: Record<string, undefined | null | string | number | boolean> = {}

      Query parameters

    Returns Promise<ApiResponse<T>>

    Promise resolving to the API response

    When the API request fails or returns an error status

  • Get CFX balance for a single address. Retrieves the current CFX balance for a specific address.

    Parameters

    • params: BalanceParams = ...

      Parameters for the balance query

      Parameters for fetching account balance. Used to query the CFX balance of a specific address at a given block.

      • address: string

        Account address to check balance for (in hex format)

      • Optionaltag?: BlockTag

        Block tag to query balance at (e.g. 'latest_state', 'latest_confirmed')

    Returns Promise<string>

    The account balance

    If the address is invalid

  • Get CFX balance for multiple addresses in a single call. Retrieves current CFX balances for multiple addresses efficiently.

    Parameters

    • params: BalanceMultiParams = ...

      Parameters for the multi-balance query

      Parameters for fetching multiple account balances. Allows querying CFX balances for multiple addresses in a single call.

      • address: string[]

        Array of account addresses to check balances for (in hex format)

      • Optionaltag?: BlockTag

        Block tag to query balances at (e.g. 'latest_state', 'latest_confirmed')

    Returns Promise<BalanceMulti>

    The account balances

    If any of the addresses are invalid

  • Get a list of normal transactions by address. Retrieves all normal (non-internal) transactions for a specific address.

    Parameters

    • params: TxlistParams

      Parameters for the transaction list query

      Parameters for getting transaction list. Used to query normal (non-internal) transactions for an address.

      • Optionalpage?: number

        Page number (1-based)

      • Optionaloffset?: number

        Page offset.

      • Optionalskip?: number

        Number of records to skip (pageSize * (pageNumber - 1)). Maximum 10000.

      • Optionallimit?: number

        Number of records per page. Maximum 100.

      • Optionalsort?: "asc" | "desc"

        Sort order by timestamp (ASC for ascending, DESC for descending)

      • OptionalminTimestamp?: number

        Minimum timestamp in seconds

      • OptionalmaxTimestamp?: number

        Maximum timestamp in seconds

      • OptionalstartBlock?: number

        Starting block number

      • OptionalendBlock?: number

        Ending block number

      • address: string

        Account address to get transactions for (in hex format)

      • Optionalstartblock?: number

        Start block number

      • Optionalendblock?: number

        End block number

      • Optionaltxhash?: string

        Transaction hash to filter by

    Returns Promise<Txlist[]>

    List of transactions

    If the address is invalid

  • Get a list of internal transactions. Retrieves all internal transactions (contract-to-contract transfers) for a specific address.

    Parameters

    • params: TxlistinternalParams

      Parameters for the internal transaction list query

      Parameters for getting internal transaction list

      TxlistinternalParams

      • Optionalpage?: number

        Page number (1-based)

      • Optionaloffset?: number

        Page offset.

      • Optionalskip?: number

        Number of records to skip (pageSize * (pageNumber - 1)). Maximum 10000.

      • Optionallimit?: number

        Number of records per page. Maximum 100.

      • Optionalsort?: "asc" | "desc"

        Sort order by timestamp (ASC for ascending, DESC for descending)

      • OptionalminTimestamp?: number

        Minimum timestamp in seconds

      • OptionalmaxTimestamp?: number

        Maximum timestamp in seconds

      • OptionalstartBlock?: number

        Starting block number

      • OptionalendBlock?: number

        Ending block number

      • address: string

        Account address to get internal transactions for

      • Optionalstartblock?: number

        Start block number

      • Optionalendblock?: number

        End block number

      • Optionaltxhash?: string

        Transaction hash

    Returns Promise<Txlistinternal[]>

    List of internal transactions

    If the address is invalid

  • Get a list of token transfers. Retrieves all token transfer events for a specific address or contract.

    Parameters

    • params: TokentxParams

      Parameters for the token transfer list query

      Parameters for getting token transaction list

      TokentxParams

      • Optionalpage?: number

        Page number (1-based)

      • Optionaloffset?: number

        Page offset.

      • Optionalskip?: number

        Number of records to skip (pageSize * (pageNumber - 1)). Maximum 10000.

      • Optionallimit?: number

        Number of records per page. Maximum 100.

      • Optionalsort?: "asc" | "desc"

        Sort order by timestamp (ASC for ascending, DESC for descending)

      • OptionalminTimestamp?: number

        Minimum timestamp in seconds

      • OptionalmaxTimestamp?: number

        Maximum timestamp in seconds

      • OptionalstartBlock?: number

        Starting block number

      • OptionalendBlock?: number

        Ending block number

      • address: string

        Account address to get token transactions for

      • Optionalcontractaddress?: string

        Contract address to filter transactions by

      • Optionalstartblock?: number

        Start block number

      • Optionalendblock?: number

        End block number

    Returns Promise<Tokentx[]>

    List of token transfers

    If the address or contract address is invalid

  • Get a list of NFT token transfers. Retrieves all NFT transfer events for a specific address or contract.

    Parameters

    • params: TokentxParams

      Parameters for the NFT transfer list query

      Parameters for getting token transaction list

      TokentxParams

      • Optionalpage?: number

        Page number (1-based)

      • Optionaloffset?: number

        Page offset.

      • Optionalskip?: number

        Number of records to skip (pageSize * (pageNumber - 1)). Maximum 10000.

      • Optionallimit?: number

        Number of records per page. Maximum 100.

      • Optionalsort?: "asc" | "desc"

        Sort order by timestamp (ASC for ascending, DESC for descending)

      • OptionalminTimestamp?: number

        Minimum timestamp in seconds

      • OptionalmaxTimestamp?: number

        Maximum timestamp in seconds

      • OptionalstartBlock?: number

        Starting block number

      • OptionalendBlock?: number

        Ending block number

      • address: string

        Account address to get token transactions for

      • Optionalcontractaddress?: string

        Contract address to filter transactions by

      • Optionalstartblock?: number

        Start block number

      • Optionalendblock?: number

        End block number

    Returns Promise<Tokentx[]>

    List of NFT transfers

    If the address or contract address is invalid

  • Get a list of blocks mined by an address. Retrieves all blocks that were mined by a specific address.

    Parameters

    • params: GetminedblocksParams

      Parameters for the mined blocks query

      Parameters for getting mined blocks

      GetminedblocksParams

      • Optionalpage?: number

        Page number (1-based)

      • Optionaloffset?: number

        Page offset.

      • Optionalskip?: number

        Number of records to skip (pageSize * (pageNumber - 1)). Maximum 10000.

      • Optionallimit?: number

        Number of records per page. Maximum 100.

      • Optionalsort?: "asc" | "desc"

        Sort order by timestamp (ASC for ascending, DESC for descending)

      • address: string

        Miner address to get blocks for

      • blocktype: "blocks"

    Returns Promise<Getminedblocks[]>

    List of mined blocks

    If the address is invalid

  • Get balance history for an address. Retrieves the historical balance of an address at a specific block number.

    Parameters

    • params: BalancehistoryParams

      Parameters for the balance history query

      Parameters for getting balance history

      BalancehistoryParams

      • address: string

        Account address

      • blockno: number

        Block number to check balance at

    Returns Promise<string>

    Historical balance information

    If the address is invalid