Questions tagged [nonce]

A random number that is only used once. It is generated at the beginning of a communication by one communication partner and has to be sent back by the other one in order to prevent replay attacks.

Filter by
Sorted by
Tagged with
30
votes
2answers
4k views

Do contracts also have a nonce?

Do contracts also have a nonce and if so how is it calculated? Usual accounts have a nonce that is increased with every transaction. However, contracts can't make transactions, they can only make ...
29
votes
3answers
10k views

What happens when a transaction nonce is too high?

From Design Rationale: One weakness of the account paradigm is that in order to prevent replay attacks, every transaction must have a "nonce", such that the account keeps track of the nonces used ...
28
votes
2answers
18k views

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

recently I got fascinated by blockchain, and started learning Ethereum. I came across the concept of the nonce in Ethereum. After researching I found out that nonce is used for two purposes. a. To ...
27
votes
3answers
3k views

Concurrency patterns for account nonce

The account nonce is the only element in the transaction structure that prevents replay attack (as explained in this very good answer). It essentially forces sequentialisation of an account's ...
16
votes
3answers
5k views

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

In Bitcoin, the BTC accounting system is based on UTXOs (Unspent Transaction Outputs), which prevents the same BTC from being spent multiple times. I heard that Ethereum has a simpler account balance ...
14
votes
2answers
5k views

How do I set the nonce for raw transactions?

A few questions about rawTransactions: Are they documented anywhere? How exactly should I set the nonce of a rawTransaction? If I start geth, and submit nothing but rawTransactions to it, then the ...
11
votes
1answer
418 views

Is it possible and sensible to deploy a contract to the same address on Mainnet and Ropsten?

Traditionally when people have deployed contracts for public use they have tended to publish separate contract addresses for Testnet and Mainnet. Often this then requires them to include code to check ...
9
votes
2answers
3k views

Truffle + Infura on Mainnet: Nonce too low error

I have the following code: const Contract = artifacts.require('./Market.sol'); module.exports = async function(callback) { let instance = await Contract.deployed(); for(var i = 0; i <=200; i+...
8
votes
1answer
548 views

Testnet First Transaction Nonce

I'm implementing a back end with different Ethereum features. I need to be able to create raw transactions. I've successfully did it using Web3 sendRawTransaction from Node.JS, but I wonder how should ...
7
votes
2answers
1k views

getTransactionCount with 'pending' not working?

Sending Ethereum transactions requires incrementing the nonce properly. In a typical application, there can be concurrent and/or consecutive requests to transfer from the same address. Most solutions ...
7
votes
1answer
727 views

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

The account I am using to submit the transaction has 10490 ETH (1.0585e+22 Wei). The transaction cost is 20477 Gas, and gas price is 300000000000. Here is the output from Geth: I0330 22:28:05.762119 ...
6
votes
2answers
668 views

Why does difficulty affect the block header nonce range?

Section 4.3.4, item 48 of the yellow paper states the has nonce, n, must be lte 2^256/current difficulty. The effect of this, assuming current difficulty is < 2^256, the range of the nonce gets ...
6
votes
2answers
826 views

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

I am trying to solve the 'Why am i getting “removed tx from pool: low tx nonce or out of funds”?' problem on my private test net. I seem to have enough funds however the rejected transaction nonce ...
5
votes
1answer
3k views

Transaction nonce management

Since transactions require a nonce that is one more than the previously mined transaction for a given address, what happens if someone sent a transaction with a low gas price that was refused by ...
4
votes
2answers
1k views

Transfer an amount between two ethereum accounts using json-rpc

I am trying to transfer some funds between 2 ethereum accounts of my own. I have a node and communicate with it using json-rpc protocol. I guess I need to use eth_sendTransaction method, but I find it ...
4
votes
1answer
268 views

Is there a technical upper limit for transaction nonces?

If I have a very busy account, let's say I'm an exchange and use a relay account or something / a hot wallet maybe to process withdrawels, which processes and creates millions of transactions, will ...
4
votes
2answers
493 views

How is the nonce in a the block header arrived at?

My understanding is that the nonce in the header of an Ethereum block is an integer within a certain range (greater than 0). However, when I look at the blocks through an online block explorer, such ...
4
votes
1answer
261 views

& instead of 0x in to address

I am trying to create a client that signs its own transactions. To keep it simple, I have stripped everything that is not absolutely required from the example code. Hence the hard coded private key ...
4
votes
1answer
261 views

How can empty accounts with a nonce of zero appear on the blockchain?

Recently I have heard about zero balance accounts with a nonce of zero appearing on the blockchain. My understanding is that any account that has been used in a transaction must have a nonce greater ...
4
votes
1answer
278 views

Why does nonce have to increment by one? Wouldn't it be sufficient to require unique nonces?

For replay protection, it would be sufficient to require a unique nonce for every transaction from the same address. More precisely, it would be sufficient to consider a new transaction T from an ...
4
votes
0answers
419 views

geth throwing header invalid error all the time

lately my ethereum node is repeatedly throwing this error: E0811 16:44:00.646126 core/blockchain.go:1128] uncle[0](30508438) header invalid: nonce for #2004585 [...
3
votes
3answers
844 views

send raw transaction without knowing nonce

I want to send raw transactions but I don't want to accidentally overwrite any transactions. Afaik when using eth.sendTransaction it automatically increments the nonce and doesn't overwrite any ...
3
votes
2answers
327 views

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

How many transactions could be included in the next new block from the same account? From my understanding, every transaction would have a unique nonce. This nonce of an account would be increased by ...
3
votes
1answer
2k views

How to properly set nonce in a web3 contract invocation?

I have this code, which works: MyToken.airdrop(wallets,amounts,{ gas: 1267051, gasPrice: 2000000000, },function(err,tx){ console.log('err is %s',err) console.log('tx is %s',tx) callback(err,...
3
votes
1answer
2k views

Reset MetaMask nonce

I am testing stuff on Ganache and am using Metamask to send transactions to simulate user behavior with the app. Now here's the issue. If I restart Ganache it resets all accounts (no problem with that)...
3
votes
1answer
1k views

Is it possible that the same address sends out two transactions at the same time

Several articles say that a transaction can be canceled or replaced with the same nonce and higher gas price. Then does this indicate that the same address can NOT send two transactions at the same ...
3
votes
1answer
212 views

Why are the dataset and MixHash required for Proof of Work?

From the yellow paper; for a block to be accepted as valid, an 8 byte number, n_rand, must be found that satisfies equation 253: = block header without n_rand and MixHash = difficulty = ...
3
votes
1answer
92 views

Is it possible to give a contract the same address from morden

I think I just lost a fraction of Ether. I accidentally sent it to the main network, but my contract only existed on Morden. I'm wondering: Can I deploy the contract retroactively? Is the address ...
3
votes
1answer
844 views

{'message': 'Nonce too low', 'code': -32000} when sending transaction on geth JSON-RPC

I am trying to send a transaction using Go Ethereum 1.4.18-stable JSON-RPC and I am getting the following error: {'message': 'Nonce too low', 'code': -32000} This is a single transaction on ...
3
votes
1answer
1k views

Send raw transactions using eth-lightwallet

I am creating a wallet app and trying to sign and send raw transactions using eth-lightwallet. function functionCallWallet(){ var fromAddr = document.getElementById('functionCaller').value ...
3
votes
1answer
30 views

A doubt about forks and mining

Suppose I'm mining a block, and I still don't find the nonce. Suddenly I receive the mined block from another node. But when I try to validate it, I find it's not right. So I discard it. What happens ...
3
votes
1answer
261 views

How many pending transactions can I create with the same nonce?

Recently I cancelled a pending transaction by resending an other transaction with the same nounce and a higher gas price in order to have the new transaction mined faster. This was useful in my case. ...
3
votes
0answers
186 views

“Removed tx from pool: low tx nonce or out of funds” on deploy empty contract

First, I know that there is a similar question, but maybe we're talking about different problems. I'm running geth-1.4.3-stable. My account balance is: 1808.90008114 ether I want to deploy a ...
2
votes
1answer
828 views

What does a position means in an ethereum Tx?

There are 2 fields in the following Ethereum Tx, named nonce & {position}. What does position mean?
2
votes
3answers
2k views

What happens if no nonce is provided for a transaction?

The nonce parameter seems to be optional for transactions. Its goal is to protect from replay attacks. In that case, why is it optional, and what happens if it's not provided? It leaves the particular ...
2
votes
1answer
459 views

getTransactionCount always returns 1048576, no matter what address

No matter what random address I use, web3.eth.getTransactionCount always prints 1048576 web3.eth.getTransactionCount("0xb222a0f8f77dbbc3a0fc87f77717ddc59cf225d7") 1048576 Let say, I change a simple ...
2
votes
2answers
61 views

What is the difference between account nonce and block nonce?

Block and accounts both use a value called "nonce" but they seem to represent something very different. For account I understand that the nonce is an integer quantity indicating the number of ...
2
votes
2answers
663 views

Why do contracts start with nonce 1?

This is a follow-up to this question. The accepted answer says: Yes, contracts have nonces. A nonce of a contract is only incremented when that contract creates another contract [...]. When a ...
2
votes
1answer
512 views

Send transaction with same nonce as another transaction but lower gas price

I want to send a transaction using web3, and I want this transaction to have the same nonce as other transactions - so far so good. The issue comes when I set a lower gasPrice than the other ...
2
votes
1answer
189 views

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

When creating raw transactions, do I have to increase the nonce always in increments of 1 or can I use any nonce as long as it has not been used before? Are there any specific rules? Could I also go ...
2
votes
2answers
772 views

Nonce selection

In the PoW system you must test different nonce until you found an hash that is compatible with the current difficulty and the current dataset. There are many miners that test many nonce at the same ...
2
votes
1answer
52 views

Can anyone tell what might had gone wrong with the transaction below?

May I know what does this transaction mean? I am running this inside my private node. Running the same transaction repeatedly none stop. Sending on average 10 transactions / sec. So I had to keep ...
2
votes
1answer
536 views

Is it possible to get the transaction count for a contract in Solidity?

Is there built-in functionality for getting the transaction count (nonce) for an account in Solidity?
2
votes
0answers
78 views

Usage of web3 provider in multiple processes

I have web application and background queue that executes long lasting tasks. Both of them using truffle-privatekey-provider with same private key to sign/send transactions. Now I ma experiencing ...
2
votes
0answers
109 views

How to set the nonce in offline transaction?

Let's suppose, I already executed 48 Tx onchain and I signed an offchain Tx with nonce 49. Now, If: I don't sign the offchain Tx with nonce, the transaction will be invalid because every Tx must ...
2
votes
0answers
425 views

Does sendRawTransaction behave the same as sendTransaction with nonce parameter.

In the Javascript API wiki it states that if you send a transaction with sendTransaction() and the optional nonce parameter set you can overwrite your pending transaction. nonce: Number - (...
1
vote
2answers
390 views

What if a malicious party sends two transactions with same nonce?

It's said nonce is used to prevent reply/double-spending attack. But an adversary can send two transactions with the same nonce, and the rest of scenario will be the same as in Bitcoin. Question 1: ...
1
vote
4answers
160 views

Why is my proofOfWork() working on every nonce?

I am running proof of work function from my deployed contract in ethereum wallet by providing any random number as nonce. As per my understanding the PoW() shouldn't work on every nonce, but in my ...
1
vote
2answers
28 views

is account nonce network dependent?

In Ethereum, does Account nonce depend on network? I mean for same address on different network, will there be different nonce?
1
vote
1answer
83 views

account nonce - what if it did not exist? [duplicate]

I can't understand how account nonce actually avoids double spending. Every answer about this on the internet follow the pattern "If you only have 50 Eth and try to send 50 to A and 50 to B with ...