The BlocksModule class encapsulates functionality for interacting with blocks on the VeChainThor blockchain.

Constructors

Properties

httpClient: HttpClient

The Thor instance used to interact with the VeChain blockchain API.

onBlockError?: ((error: Error) => undefined)

Error handler for block-related errors.

Methods

  • Retrieves all addresses involved in a given block. This includes beneficiary, signer, clauses, gas payer, origin, contract addresses, event addresses, and transfer recipients and senders.

    Parameters

    Returns string[]

    • An array of addresses involved in the block, included empty addresses, duplicate elements are removed.
  • Retrieves the base fee per gas of the best block.

    Returns Promise<string>

    A promise that resolves to the base fee per gas of the best block.

  • Asynchronously retrieves a reference to the best block in the blockchain.

    This method first calls getBestBlockCompressed() to obtain the current best block. If no block is found (i.e., if getBestBlockCompressed() returns null), the method returns null indicating that there's no block to reference. Otherwise, it extracts and returns the first 18 characters of the block's ID, providing the ref to the best block.

    Returns Promise<string>

    A promise that resolves to either a string representing the first 18 characters of the best block's ID, or null if no best block is found.

    @Example: const blockRef = await getBestBlockRef(); if (blockRef) { console.log(Reference to the best block: ${blockRef}); } else { console.log("No best block found."); }

  • Retrieves details of a compressed specific block identified by its revision (block number or ID).

    Parameters

    • revision: string | number

      The block number or ID to query details for.

    Returns Promise<CompressedBlockDetail>

    A promise that resolves to an object containing the details of the compressed block.

  • Retrieves details of an expanded specific block identified by its revision (block number or ID).

    Parameters

    • revision: string | number

      The block number or ID to query details for.

    Returns Promise<ExpandedBlockDetail>

    A promise that resolves to an object containing the details of the expanded block.