Hot answers tagged

80

Summary Transactions with too low a nonce get immediately rejected. Transactions with too high a nonce get placed in the transaction pool queue. If transactions with nonces that fill the gap between the last valid nonce and the too high nonce are sent and the nonce sequence is complete, all the transactions in the sequence will get processed and mined. When ...


47

What is nonce in Ethereum? If you refer the Glossary at Github Wiki, there are two types of nonce used in Ethereum. Account nonce - It's simply the transaction count of an account Account nonce: a transaction counter in each account. This prevents replay attacks where a transaction sending eg. 20 coins from A to B can be replayed by B over and over to ...


41

Yes, contracts have nonces. EIP 161 made the contract nonce start at 1, and before EIP 161 the nonce would start at 0. A nonce of a contract is only incremented when that contract creates another contract (@zanzu's YP reference). When a contract invokes a function on another contract, a so called "internal transaction" (in http://live.ether.camp), the ...


16

Each account has a globally accessible nonce which prevents same-chain replay attacks and double spends. The nonce is the sequence number, which miners check, because a block that has a transaction with an incorrect nonce is an invalid block (other miners won't build on top of it). (The nonce does not protect against cross-chain replay attacks.) Second ...


16

I haven't yet got to the point where I can test any of these things, but my gut feel is that the Singleton Nonce Manager would be the way to go, with a few enhancements: Make it a singleton transaction sender That has a maximum buffer or 'head' of pending transactions per 'from' address that matches or is less than the maximum number of transactions that ...


13

The answer to your question can be found in the yellow paper: nonce: A scalar value equal to the number of trans- actions sent from this address or, in the case of accounts with associated code, the number of contract-creations made by this account Remember: in Ethereum, contracts are accounts with code associated with them.


10

If you're using Truffle with Infura directly (which it sounds like you are, although it's unclear why you mention MetaMask), you need to be aware that Infura is running on a server farm. If you submit a transaction, the node that receives it first may not be the same node that handles the next transaction, or that handles the eth_getTransactionCount call ...


9

I am not providing an answer here but I am elaborating on a small discussion with @eth which is relevant to the OP's question, and I wanted to share what I have learnt, thanks to @eth and a bit of reading around. The misunderstanding that I had was that all nodes execute code when a transaction invokes that code, and therefore assumed that the result of the ...


9

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 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). Not as far as I know.


8

It looks like you are on a testnet, which implements an initial nonce of 2^20 (0x100000). The reason this is used is to prevent replay attacks on the main net, where transactions on the testnet are relayed to main net nodes, causing real ether to be sent. By setting the initial nonce higher than it could conceivably reach on the main network, we prevent ...


8

Firstly, it's 'nonce', not 'nounce'. i) Yes, each address has a nonce. Addresses can have the same nonce, and often do. ii) Yes, all nodes on the same blockchain have recorded the same nonce for each address, because the nonces are stored inside the blockchain. b) The nonce is basically just a counter that keeps track of how many transactions an address ...


7

The bit of source code that generates this error comes from https://github.com/ethereum/go-ethereum/blob/4044a8cea44cd4cee3a8ddaf51a76b71c9d22042/core/tx_pool.go#L489-L502 and is called within the function tx_pool.go:validate_pool(...) . ... if past := state.GetNonce(sender) > tx.Nonce(); past || balance.Cmp(tx.Cost()) < 0 { // Remove an already ...


6

Apparently there's a nuance with the nonce... my error was I was setting the nonce to web3.eth.getTransactionCount() + 1, which left a gap between prior transaction nonce and next transaction nonce (nonces are 0 indexed, transactions are indexed from 1, that's the root of the error). It so appears that you are not allowed to increment the nonce by 2 and ...


5

You're correct that all subsequent transactions would be refused. So with Geth, you can rebroadcast with a higher fee (gas price) by using eth.resend (the nonce will remain the same). eth.resend(tx, optional gas price, optional gas limit) Example: eth.sendTransaction({from: eth.accounts[0], to: "...", gasPrice: "1000"}) var tx = eth.pendingTransactions[0]...


5

eth_sendTransaction can be used for sending Ether, for creating contracts and calling contract function. It all depends on the parameters. For just sending Ether, you'd want to fill the value, to and from fields. For creating contracts, you'd leave the to empty but fill in data. For calling a contract function, you'd fill in both to and data, and optionally ...


5

It looks like you are on a testnet, which implements an initial nonce of 2^20 = 0x100000 = 1048576 More details here: https://github.com/ethereum/wiki/wiki/Morden#details Initial Account Nonce (IAN) is 2^20 (instead of 0 in all previous networks). By setting an initial nonce higher than it could possibly reach on the main Ethereum network, they prevent ...


5

In that equation, the fancy n doesn't refer to nonce. Hn refers to nonce. Here's the full, put together equation which might clarify it: More info on difficulty: Given an approximately uniform distribution in the range [0,2^64), the expected time to find a solution is proportional to the difficulty, Hd. or, more frankly stated: This mechanism ...


5

This is indeed a bug, as confirmed recently by members of the geth team. Bug Report Until then, you will indeed need to manage nonce on the application side.


5

Transactions with ascending nonces can be included in the same block, so there's no particular limit on the number of transactions from the same account.


5

The nonce is part of the transaction data, so it contributes to the transaction hash, which is what you sign with the private key. So you need to know the nonce you want to use before signing the transaction.


5

According to this documentation, there is a reset button in Metamask. https://metamask.helpscoutdocs.com/article/36-resetting-an-account See also https://github.com/MetaMask/metamask-extension/issues/3479


5

Nonce is the number of transactions the source account has made so far starting from 0, not from 1, position is the number of this transaction (mined) inside the block.


4

Yes, the nonce is zero indexed. Given that it's zero indexed and you have 7 executed transactions, means that the last used nonce was 6. So the next valid one needed for the pool to accept it is 7 (i.e. the same as eth.getTransactionCount).


4

The nonce is always the sender's transaction count. Receiving a transaction doesn't affect the nonce. When a transaction is processed, all pending transactions with a nonce lower than the confirmed transaction are cancelled. The transaction count and nonce can be set by web3.eth.getTransactionCount(). Pending transactions must be taken into account. nonce =...


4

From github - Go Ethereum - core/types/transaction.go, lines 46-54: type txdata struct { AccountNonce uint64 Price, GasLimit *big.Int Recipient *common.Address `rlp:"nil"` // nil means contract creation Amount *big.Int Payload []byte V byte // signature R, S *big.Int // ...


4

How does nonce really help to prevent double spending attack? If there are 2 transactions with the same nonce and from same account, the transaction that is first included in the blockchain will be considered as valid and the other one will be rejected. This is the concept used to override transactions in ethereum. If you have a pending transaction and you ...


4

There's really no hashing involved in this nonce, the value is arbitrary and the definition "64-bit string hash" is misleading, IMHO. A better definition for nonce in this specific context can be found in the Ethereum Yellowpaper (page 5, top right). There, the nonce is defined as "A 64-bit value (...)". It's actually just any value between 0 and ...


3

To simplify the answer, I will use decimal numbers instead of hexadecimal numbers. And instead of 2^256 in the numerator, I will use 10^10 (= 10,000,000,000). (A) When difficulty is set to 1,000,000 , the "target" is to find a number below 10^10 / 1,000,000 . This is 10,000,000,000 / 1,000,000 = 10,000 . We have to find a hash function result in the range ...


3

In my understanding, d is, as said in the yellow paper page 6, the current DAG. Where Hn is the new block’s header H, but without the nonce and mix-hash components, d being the current DAG, a large data set needed to compute the mix-hash, and PoW is the proof-of-work function (see section 11.5): this evaluates to an array with the first item being the ...


3

While it is theoretically possible, it's not very practical. The address of a contract is computed by sha3 hashing the creator's address with the creator accounts nonce. Thus, if you wait until your nonce matches, and then create a contract with the same account, it will have the same address as the Morden contract, and thus access to the funds. The issue ...


Only top voted, non community-wiki answers of a minimum length are eligible