0

First of all, I'm new to the Erthereum world, I need some help in measuring the total delay (time) require for confirming the transaction. I have a decentralized application over a Rinkeby network, and I want to know, how long the process will take until confirming the transaction?

I have been read in many papers that a total delay is 10 seconds, 15 seconds, 5.5 sec...etc My question:

How they measure these numbers "10 sec,15 sec..etc"? Is it manually, or there is a specific tool or way for measuring the total delay (time).

  • The answer is that an elapse of 12 blocks guarantees that your transaction remains in the blockchain with a probability of 99.99%. So this factor is what typically being measured. How many seconds does it take? On mainnet, it is currently 15-17 per blocks, but it will not necessarily remain the same for eternity. On rinkeby... well, who cares? Just measure 12 blocks instead of however many seconds. – goodvibration Apr 27 at 20:18
  • So appreciate your reply, but actually I couldn't understand the provided information. I'm looking to determine the amount of time need to confirm the transaction. For example, I have to wait 10 seconds to approve my transaction and add it to the block. How can I measure the 10 Seconds? – Byo0ona Apr 27 at 21:55
  • Don't measure seconds, measure blocks. – goodvibration Apr 28 at 8:32
  • Could you expalin what do you mean in "An elapse of 12 blocks guarantees that your transaction remains in the blockchain." Thanks a lot – Byo0ona Apr 28 at 19:32
  • You execute a transaction at block N. If the transaction-hash is still valid at block N+12, then the probability that the transaction will remain in the blockchain forever is higher than 99.99%. So you don't need to measure how many seconds have elapsed since you executed the transaction, you need to measure how many blocks have elapsed since you executed the transaction. – goodvibration Apr 28 at 19:53
0

I'm working on the exact same thing and the way i measure time it takes and "block-latency" for transaction to finish is by taking the following steps. I'm using web3.js

  1. Get current block. currBlock = web3.eth.getBlockNumber()
  2. Start a timer. startTime = Date.now()
  3. Fire off a transaction
  4. When resolving the promise (the transaction) in the .then(receipt) elapsed time can be caluclated with Date.now() - startTime and calculate the block latency by doing receipt.blocknumber - currBlock

Below is an example of how you could do this assuming you have an array of promises/transactions

async function calculateLatencies(promisesArr) {
  const currBlock = await web3.eth.getBlockNumber()
  let startTime = Date.now()
  await Promise.all(promisesArr)
    .then(async (receipts) => {
      let elapsedTime = Date.now - startTime
      let lastBlock = receipts[0].blockNumber
      receipts.forEach((receipt) => {
        lastBlock =
          receipt.blockNumber > lastBlock ? receipt.blockNumber : lastBlock
      })
      let blockLatency = lastBlock - currBlock
    })
}

| improve this answer | |
  • Thanks a lot for sharing your code and helpful info. Did you try it on the Rinkeby network? Because I noticed from EtherScan, the block latency is 15 seconds between all blocks regardless of the gas price? – Byo0ona Apr 28 at 20:43
  • @Byo0ona No problem!:) If I answered your question please feel free to accept the answer. My contract is on the Ropsten network. Rinkeby is different to Ropsten in that it employs PoA rather than PoW so it is not a good network to gauge "performance" of how your contract would behave on the mainnet. A link to a post about the differences between rinkeby and mainnet Rinkeby vs mainnet – Conviley Apr 29 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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