1

I am currently using api.transact to send the transaction to the eos Blockchain. I want a way to check for irreversile status so that I can confirm that the transaction has happened successfuly.

  • Is there a way to check/monitor for irreversible status so that I can notify the user when they transact?
0

2 Answers 2

1

You can check this by getting the transaction information first using

(async () => {
  await rpc.history_get_transaction('b3598da4e007173e6d1b94d7be306299dd0a6813d114cf9a08c8e88a5756f1eb', 46632826)
})();

which returns result like:

{
  id: 'b3598da4e007173e6d1b94d7be306299dd0a6813d114cf9a08c8e88a5756f1eb',
  trx: {
    receipt: {
      status: 'executed',
      cpu_usage_us: 2070,
      net_usage_words: 14,
      trx: [Array]
    },
    trx: {
      expiration: '2019-08-28T03:45:47',
      ref_block_num: 36720,
      ref_block_prefix: 654845510,
      max_net_usage_words: 0,
      max_cpu_usage_ms: 0,
      delay_sec: 0,
      context_free_actions: [],
      actions: [Array],
      transaction_extensions: [],
      signatures: [Array],
      context_free_data: []
    }
  },
  block_time: '2019-08-28T03:45:21.500',
  block_num: 46632826,
  last_irreversible_block: 46784285,
  traces: []
}

Check if the last_irreversible_block is greater than block_num then the transaction is irreversible .

1
  • thanks a million! Commented Oct 25, 2022 at 21:02
0

check this out for some ideas: https://github.com/liquidapps-io/eosio-push-guarantee/blob/main/src/index.ts

You can get the block the trx was executed in, confirm the trx is in the block, monitor the last irr block from the get info RPC call, and consider the trx irreversible if it was executed in a block prior to the last reported LIB.


https://mainnet.eosn.io/v1/chain/get_info

{
  "server_version": "8f29da18",
  "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  "head_block_num": 175138182,
  -> "last_irreversible_block_num": 175137856,
  "last_irreversible_block_id": "0a706440ae187e6e1c44deddb2425d5dc809ee3e75544961da3d19e4c4b64277",
  "head_block_id": "0a7065862fee5c95c3157e8cb19354e438efe9dbf60af674f79bb170f2cf36e5",
  "head_block_time": "2021-03-26T01:43:36.500",
  "head_block_producer": "eosrapidprod",
  "virtual_block_cpu_limit": 200000,
  "virtual_block_net_limit": 1048576000,
  "block_cpu_limit": 200000,
  "block_net_limit": 1048576,
  "server_version_string": "v2.0.11",
  "fork_db_head_block_num": 175138182,
  "fork_db_head_block_id": "0a7065862fee5c95c3157e8cb19354e438efe9dbf60af674f79bb170f2cf36e5",
  "server_full_version_string": "v2.0.11-8f29da1845c1f1a3479bc32dce0238e9873a8bf4-dirty"
}

In your UI you can use eosjs here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.