Wrapper class for account-related operations. Extends BaseWrapper to provide formatted data responses.

// Create a new account wrapper instance
const account = new AccountWrapper({ target: 'mainnet' });

// Get account balance
const balance = await account.getBalance({
address: '0x1234...',
tag: 'latest_state'
});

// Get multiple account balances
const balances = await account.getBalanceMulti({
address: ['0x1234...', '0x5678...']
});

Hierarchy

  • BaseWrapper
    • AccountWrapper

Constructors

  • Creates a new AccountWrapper instance

    Parameters

    • config: ApiConfig = ...

      API configuration options

      API configuration options. Contains settings for connecting to the Conflux eSpace Scanner API.

      • target: ConfluxTarget

        Target network environment

      • OptionalapiKey?: string

        API key for authentication

      • Optionalhost?: string

        Custom API host URL

    Returns AccountWrapper

Properties

account: AccountModule

Core account module instance

Methods

  • Format a timestamp value to a human-readable date string.

    Parameters

    • value: string | number

      The timestamp to format

    Returns string

    Formatted date string

  • Format a CFX value with appropriate decimal places and units.

    Parameters

    • value: string

      The CFX value to format

    Returns string

    Formatted CFX value

  • Format a gas value with appropriate units.

    Parameters

    • value: string

      The gas value to format

    Returns string

    Formatted gas value

  • Format a numeric value with appropriate separators.

    Parameters

    • value: string | number

      The number to format

    Returns string

    Formatted number string

  • Format a value with specified decimal places.

    Parameters

    • value: string

      The value to format

    • decimals: number

      Number of decimal places

    Returns string

    Formatted value with specified decimals

  • 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')

    • returnRaw: boolean = false

      If true, returns the raw balance in Drip without formatting

    Returns Promise<string>

    The account balance, formatted with CFX units unless returnRaw is true

    const balance = await account.getBalance({
    address: '0x1234...',
    tag: 'latest_state'
    });
    // Returns: '123.45 CFX'

    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')

    • returnRaw: boolean = false

      If true, returns the raw balances in Drip without formatting

    Returns Promise<BalanceMulti>

    Array of [address, balance] pairs

    const balances = await account.getBalanceMulti({
    address: ['0x1234...', '0x5678...'],
    tag: 'latest_state'
    });
    // Returns: [['0x1234...', '123.45 CFX'], ['0x5678...', '67.89 CFX']]

    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

    • returnRaw: boolean = false

      If true, returns the raw transaction data without formatting

    Returns Promise<Txlist[]>

    List of transactions with formatted values

    const txs = await account.getTransactionList({
    address: '0x1234...',
    page: 1,
    offset: 10,
    sort: 'desc'
    });

    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

    • returnRaw: boolean = false

      If true, returns the raw transaction data without formatting

    Returns Promise<Txlistinternal[]>

    List of internal transactions with formatted values

    const txs = await account.getInternalTransactionList({
    address: '0x1234...',
    page: 1,
    offset: 10,
    sort: 'desc'
    });

    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

    • returnRaw: boolean = false

      If true, returns the raw transfer data without formatting

    Returns Promise<Tokentx[]>

    List of token transfers with formatted values

    const transfers = await account.getTokenTransfers({
    address: '0x1234...',
    contractaddress: '0x5678...',
    page: 1,
    offset: 10,
    sort: 'desc'
    });

    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

    • returnRaw: boolean = false

      If true, returns the raw transfer data without formatting

    Returns Promise<Tokentx[]>

    List of NFT transfers with formatted values

    const transfers = await account.getNFTTransfers({
    address: '0x1234...',
    contractaddress: '0x5678...',
    page: 1,
    offset: 10,
    sort: 'desc'
    });

    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"
    • returnRaw: boolean = false

      If true, returns the raw block data without formatting

    Returns Promise<Getminedblocks[]>

    List of mined blocks with formatted values

    const blocks = await account.getMinedBlocks({
    address: '0x1234...',
    blocktype: 'blocks',
    page: 1,
    offset: 10
    });

    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

    • returnRaw: boolean = false

      If true, returns the raw balance in Drip without formatting

    Returns Promise<string>

    Historical balance with formatted values

    const balance = await account.getBalanceHistory({
    address: '0x1234...',
    blockno: 12345678
    });
    // Returns: '123.45 CFX'

    If the address is invalid