3

1.I have a need to initiate multiple transactions to the same contract address in the fastest time and get confirmation from the network. Means that multiple transactions are recorded in the same block.

2.By use Web3.py and Infura.io .On the kovan network test was pass.But on Mainnet each transaction initiated at the same time was confirmed on the block separated by 1 block.

3.Gas limit was 1 million,gas price was instant maximum price.

4.Nonce is no question.I get the first transaction nonce through getTransactionCount(), then the second transaction is set by myself (nonce+1) to ensure the correctness of the nonce, and the test is passed on the kovan network.

enter image description here

enter image description here

0

Of course there is way more transaction congestion on the main net than on the test nets, the miners' mempools are full. While on the testnets the blocks are not always full ( == reach gas limit), on the mainnet the transactions have to be chosen carefully to fit the chosen blockgaslimit as closely as possible.

Might also be that the (miners') clients are configured in a way to have more equality among all senders and only take one transaction per sender per block (if not some conditions are given maybe - it's not toally impossible to have more than one transaction per sender per block, but this occasion is very, very rare.)

  • it's not toally impossible to have more than one transaction per sender per block This happens all the time, I wouldn't say it's rare. Nearly every block has multiple transactions from at least one address – Raghav Sood Aug 12 '18 at 21:37
  • yes,I have found that other people's contract address have multiple transactions from the same address in the one block. – kyle xu Aug 13 '18 at 2:54
0

You can increase your chances by increasing gas price, but there is no way to guarantee that multiple transactions will be included in the same block. (apart from becoming a miner, yourself)

If you're trying to race to do something between the first and second transaction, note that miners can "front-run" you. They can intentionally delay your second transaction and run their own in between. If there is an economic incentive for them to do so, they probably will.

If you must have two function calls happen in the same block, then you can combine them by using a smart contract which calls both functions sequentially. So if transaction 1 is calling contract A, function foo(), and transaction 2 is calling contract B, function bar(), then you can have a contract call:

contract C {
  function grouped() {
    A.foo();
    B.bar();
  }
}

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.