0

I'm trying to understand block time and speed of transaction. For now I'm testing on Binance Smart Chain and then I will go to ethereum network.

I have a simple code in nodejs using web3 library, I'm connected to a node via websocket :

  • I subscribe to 'newBlockHeaders' events
  • Once I get a new block I use web3.eth.accounts.signTransaction and web3.eth.sendSignedTransaction to send a test transaction

My transaction is ALWAYS 2 blocks after the received block event. I want it to be 1 block after.

Looks like confirmation time is about 6 sec so 2 blocks makes sense. But how to place my transaction on just 1 block after the event received?

1

When a client receives a block it is likely the next block is already being mined. Using a very high gas price may encourage miners to include it in the next block but even in that case it is not a sure thing. Also a chain reorg may affect the order later.

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.