As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

106 votes
Accepted

What happens when a transaction nonce is too high?

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 ...
tsarbucks.eth employeeoftheday's user avatar
62 votes
Accepted

What is nonce in Ethereum? How does it prevent double spending?

What is nonce in Ethereum? If you refer to 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: ...
Achala Dissanayake's user avatar
48 votes
Accepted

Do contracts also have a nonce?

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 ...
eth's user avatar
  • 83.3k
21 votes
Accepted

How does the Ethereum ETH accounting system work and prevent double-spends?

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 ...
eth's user avatar
  • 83.3k
21 votes
Accepted

Concurrency patterns for account nonce

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 ...
Sentinel's user avatar
  • 1,218
14 votes

Do contracts also have a nonce?

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, ...
zanzu's user avatar
  • 5,270
13 votes
Accepted

Truffle + Infura on Mainnet: Nonce too low error

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 ...
James_pic's user avatar
  • 1,100
10 votes

How does the Ethereum ETH accounting system work and prevent double-spends?

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 ...
T9b's user avatar
  • 1,175
10 votes
Accepted

How do I set the nonce for raw transactions?

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, ...
Péter Szilágyi's user avatar
10 votes

Transaction stuck because of low gas price

Looking at your transaction, you have set a gas price of 4 gwei. Though not very high for current traffic, this should eventually get picked up. You can check gas prices and traffic on ETH Gas watch. ...
wslyvh's user avatar
  • 478
9 votes

What is nonce in Ethereum? How does it prevent double spending?

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 ...
Jesbus's user avatar
  • 10k
9 votes
Accepted

Does nonce increase when the transaction fail?

TX3 nonce=? 2 A transaction is context-sensitive, so it can succeed or fail depending on what came before. Why? A transaction that has failed has definitely failed and its failure is recorded as ...
Rob Hitchens's user avatar
  • 54.3k
8 votes
Accepted

Testnet First Transaction Nonce

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 ...
Tjaden Hess's user avatar
  • 36.2k
8 votes
Accepted

Reset MetaMask nonce

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/...
ivicaa's user avatar
  • 7,459
8 votes
Accepted

How to properly set nonce in a web3 contract invocation?

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 (...
shaharsol's user avatar
  • 519
7 votes
Accepted

Why am i getting "removed tx from pool: low tx nonce or out of funds"?

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 ...
tsarbucks.eth employeeoftheday's user avatar
7 votes
Accepted

Transaction nonce management

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, ...
eth's user avatar
  • 83.3k
7 votes
Accepted

Transfer an amount between two ethereum accounts using json-rpc

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 ...
kobigurk's user avatar
  • 413
7 votes
Accepted

What does a position means in an ethereum Tx?

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.
Nulik's user avatar
  • 3,911
6 votes
Accepted

getTransactionCount always returns 1048576, no matter what address

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 (...
jrbedard's user avatar
  • 524
6 votes

getTransactionCount with 'pending' not working?

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.
Andrew Warshaver's user avatar
6 votes
Accepted

send raw transaction without knowing nonce

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 ...
user19510's user avatar
  • 27.6k
5 votes

Why does difficulty affect the block header nonce range?

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 ...
tayvano's user avatar
  • 15.8k
5 votes

How do I set the nonce for raw transactions?

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 ...
Timothy Gonzalez's user avatar
5 votes

how many transactions could be included in a new block from the same account?

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.
Edmund Edgar's user avatar
  • 16.7k
5 votes
Accepted

Getting and setting the nonce for a transaction

The nonce in the main ethereum network starts at 0 for each account and increases each time a transaction originates from that account. You can just count the outbound transactions on etherscan.io, ...
user19510's user avatar
  • 27.6k
5 votes
Accepted

After a suicide operation, is contract’s nonce reset to 0?

After a suicide operation, is contract’s nonce reset to 0 ? It seems the answer is yes. An easy way to verify such a statement is to find a suicided contract and query a node to check its nonce. For ...
clement's user avatar
  • 4,202
4 votes
Accepted

Should correct transaction nonce be one less than account transaction count?

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....
Péter Szilágyi's user avatar
4 votes
Accepted

Can I use any nonce as long as it is not previously been used?

No, the nonce needs to equal the number of transactions sent from the address; so that also means no jumping around. The account state comprises the following four fields: nonce: A scalar value ...
eth's user avatar
  • 83.3k
4 votes
Accepted

Is there a technical upper limit for transaction nonces?

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 ...
tsarbucks.eth employeeoftheday's user avatar

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