[Ethereum] Multiple transactions from same address

addressesminingtransactions

I would like to create multiple transaction from the same address at the same time. Since every transaction needs nonce (tx count of the sender address) I can ask geth for the current count and create first tx, then increment nonce and create the next one and so on.
Problems as I see them are:

  1. if one transaction does not get mined, none of the following will get mined (since nonce will be incorrect).
  2. what happens if some tx gets included in one block and some in the other block, order might become wrong.
    Is this reasoning correct?

If it is not, I'm wondering is there any better approach for this case.

Best Answer

You have not stated whether you are sending your transactions while connected to the blockchain via geth (on-blockchain), or whether you are crafting your transaction while not connected to the blockchain (off-blockchain).

The answer by Paul S is referring to the off-blockchain crafting of transaction where you have to specify a nonce in the raw transactions you are then executing on the blockchain.

If you are sending your transaction on-blockchain, you can use the eth.sendTransaction(...) without a nonce.

For example, here are 3 transactions from the same "from" account to the same "to" account. There is no need to specify a nonce as it is automatically generated:

> eth.sendTransaction({from: '0x5e83b635f96da0752f991f0ebddc31249f452dea', to: '0x68acc3a13441b69016560d23e134c7931bbb27bb', value: web3.toWei(1, "ether")});
"0x92d6d2285b198b6b5cf80eca6d4292c9675fb53f47f786063df600d3be06dd09"
> eth.sendTransaction({from: '0x5e83b635f96da0752f991f0ebddc31249f452dea', to: '0x68acc3a13441b69016560d23e134c7931bbb27bb', value: web3.toWei(2, "ether")});
"0x0c1280c8b2f38aec032494913c1d0e65edd511fcd15e2424483f9bbf51c7172e"
> eth.sendTransaction({from: '0x5e83b635f96da0752f991f0ebddc31249f452dea', to: '0x68acc3a13441b69016560d23e134c7931bbb27bb', value: web3.toWei(3, "ether")});
"0x8b6998eea8b343a0f754cf2732a1f28caac3acdfbe97cca69f244f0614ea546a"

> eth.getTransaction("0x92d6d2285b198b6b5cf80eca6d4292c9675fb53f47f786063df600d3be06dd09");
{
  blockHash: "0x8456088424a4cacd8b394b4e11732e3c96ca77ab4a999c6ba62b38ab61116b58",
  blockNumber: 225,
  from: "0x5e83b635f96da0752f991f0ebddc31249f452dea",
  gas: 90000,
  gasPrice: 20000000000,
  hash: "0x92d6d2285b198b6b5cf80eca6d4292c9675fb53f47f786063df600d3be06dd09",
  input: "0x",
  nonce: 0,
  to: "0x68acc3a13441b69016560d23e134c7931bbb27bb",
  transactionIndex: 0,
  value: 1000000000000000000
}
> eth.getTransaction("0x0c1280c8b2f38aec032494913c1d0e65edd511fcd15e2424483f9bbf51c7172e");
{
  blockHash: "0x8456088424a4cacd8b394b4e11732e3c96ca77ab4a999c6ba62b38ab61116b58",
  blockNumber: 225,
  from: "0x5e83b635f96da0752f991f0ebddc31249f452dea",
  gas: 90000,
  gasPrice: 20000000000,
  hash: "0x0c1280c8b2f38aec032494913c1d0e65edd511fcd15e2424483f9bbf51c7172e",
  input: "0x",
  nonce: 1,
  to: "0x68acc3a13441b69016560d23e134c7931bbb27bb",
  transactionIndex: 1,
  value: 2000000000000000000
}
> eth.getTransaction("0x8b6998eea8b343a0f754cf2732a1f28caac3acdfbe97cca69f244f0614ea546a");
{
  blockHash: "0x8456088424a4cacd8b394b4e11732e3c96ca77ab4a999c6ba62b38ab61116b58",
  blockNumber: 225,
  from: "0x5e83b635f96da0752f991f0ebddc31249f452dea",
  gas: 90000,
  gasPrice: 20000000000,
  hash: "0x8b6998eea8b343a0f754cf2732a1f28caac3acdfbe97cca69f244f0614ea546a",
  input: "0x",
  nonce: 2,
  to: "0x68acc3a13441b69016560d23e134c7931bbb27bb",
  transactionIndex: 2,
  value: 3000000000000000000
}
Related Topic