[Ethereum] How to set the nonce for raw transactions

go-ethereumjson-rpcnonceraw-transaction

A few questions about rawTransactions:

  1. Are they documented anywhere?
  2. How exactly should I set the nonce of a rawTransaction? If I start geth, and submit nothing but rawTransactions to it, then the nonces are simply numbered 1, 2, 3, …, correct? How about if I mix in some non-raw (sendTransaction) transactions, from a different address? For example, suppose I submit eth_sendTransaction, eth_sendTransaction, eth_sendRawTransaction. Should the nonce of the first raw transaction be 1 or 3?
  3. Has anything changed in the way rawTransaction nonces are handled, between develop and master?
  4. Does the answer to (2) change if the sendTransaction(s) and raw transactions are from different addresses?

Edited (4/2/2016): the specific error I'm getting when I attempt to send raw transactions to geth: -32000: Nonce too low. (This is why I'm so focused on the nonce value…)

Here is an example of the client-side transaction, prior to being wrapped and packaged by ethereumjs-tx:

{
  "to": "0x895d32f2db7d01ebb50053f9e48aacf26584fe40",
  "from": "0x6bcf3d525c425965a40fb77b1fe6461eeced67d7",
  "gasLimit": "0x2fd618",
  "nonce": 1,
  "value": "0x0",
  "data": "0x5f92896e00000000000000000000000000000000000000000000000000000000000f69b5",
  "gasPrice": "0x4a817c800"
}

Anything obviously wrong there…?

Best Answer

  1. A raw transaction is the RLP encoded value of a signed transaction, i.e. everything included as defined by the yellow paper page 4, section 4.2
  2. Nonces must already be included in the raw transaction, you cannot set it. Geth does not set it. (Since the signature that is also included is based on it).
  3. Not as far as I know.
Related Topic