getblock

How to use it

// yarn add @tatumio/tatum
import { TatumSDK, Tron, Network } from '@tatumio/tatum'

const tatum = await TatumSDK.init<Tron>({network: Network.TRON})

const res = await tatum.rpc.getBlock('1000000', {
  detail: false,
})

await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs

Overview

The getBlock method allows you to query block header information or entire block information according to block height or block hash. This can be particularly useful in situations where you need to inspect the contents of a particular block in the TRON blockchain for transaction verification or data analysis.

Parameters

  • idOrNum (string): This parameter can be the block height or the block hash. Not providing a value means that it will query the latest block.

  • options (object, optional): This is an optional parameter that can include:

    • detail (boolean, optional): If set to true, it queries the entire block information including the header and body. If false, it only queries the block header information.

Return Object

The method returns a Promise that resolves to an object with the following properties:

  • blockID (string): The block hash.

  • block_header (object)

    • raw_data (object)

      • timestamp (integer): The timestamp of the block.

      • txTrieRoot (string): The root of the transaction merkle tree.

      • parentHash (string): The parent block hash.

      • number (integer): The block number.

      • witness_id (integer): The witness id.

      • witness_address (string): The witness address.

      • version (integer): The version.

      • accountStateRoot (string): The root of the account state tree.

    • witness_signature (string): The signature of the Super Representative (SR).

  • transactions (Array): Contains transaction information in the block.

    • raw_data.contract - The main content of the transaction, contract is a list, but only one element is used at present. Different types of transactions have different contract contents. For example, for a TRX transfer type transaction, the contract will include the transfer amount, receiver address and other information. TRON supports multiple types of contracts, please refer to the official documentation Types of Transaction.

    • raw_data.ref_block_bytes - The height of the transaction reference block, using the 6th to 8th (exclusive) bytes of the reference block height, a total of 2 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.

    • raw_data.ref_block_hash - The hash of the transaction reference block, using the 8th to 16th (exclusive) bytes of the reference block hash, a total of 8 bytes. The reference block is used in the TRON TAPOS mechanism, which can prevent a replay of a transaction on forks that do not include the referenced block. Generally, the latest solidified block is used as the reference block.

    • raw_data.expiration - Transaction expiration time, beyond which the transaction will no longer be packed. If the transaction is created by calling the java-tron API, its expiration time will be automatically set by the node to the value of adding 60 seconds to the timestamp of the node's latest block. The expiration time interval can be modified in the node's configuration file, the maximum value cannot exceed 24 hours.

    • raw_data.data - Transaction memo.

    • raw_data.timestamp - Transaction timestamp, set as the transaction creation time.

    • raw_data.fee_limit - The maximum energy cost allowed for the execution of smart contract transactions. Only deploying and triggering smart contract transactions need to be set, others not.

    • signature - The sender's signature for the transaction. This proves that the transaction could only have come from the sender and was not sent fraudulently.

    • txID - transaction id

HTTP Request Example

{
  "id_or_num": "1000000",
  "detail": true
}

HTTP Response Example

{
  "blockID": "00000000000f424013e51b18e0782a32fa079ddafdb2f4c343468cf8896dc887",
  "block_header": {
    "raw_data": {
      "number": 1000000,
      "txTrieRoot": "e2dd42daa9c853e070df1e4fc927851a7438c601fb12cf945922629d5cec187b",
      "witness_address": "41f16412b9a17ee9408646e2a21e16478f72ed1e95",
      "parentHash": "00000000000f423fbccd9cdb9e410eabdf9f94145cf5b71a678b8b9616619125",
      "version": 9,
      "timestamp": 1578594852000
    },
    "witness_signature": "179caed28b3d129dee6d553ae6761a8c8698f890e5f38e062d56e2d0d0b8c9a20317b7753b3fd1be261935d6182434a6c057f8926f25027b9859cde3da3a655300"
  },
  "transactions": [
    {
      "ret": [
        {