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 contract invokes a function on another contract, a so called "internal transaction" (in http://live.ether.camp), the nonce is not incremented.

The nonce can be obtained by using web3.eth.getTransactionCount.

So far, so good. But when I use web3.eth.getTransactionCount with a recently deployed contract, the value is 1, not 0, despite that contract not having created any other contract.

Why is that happening?

2 Answers 2


From https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md:

a. Account creation transactions and the CREATE operation SHALL, prior to the execution of the initialisation code, increment the nonce over and above its normal starting value by one (for normal networks, this will be simply 1, however test-nets with non-zero default starting nonces will be different).

This is a fairly recent change, which explains why you can find older contracts with a nonce of 0.

As to the why, my (limited) understanding is that it's an attempt to make sure that "empty" accounts and "non-existent" accounts are the same (zero nonce, zero balance, and empty code), which allows for clean-up of empty accounts.


@smarx found the answer with EIP 161.

Before EIP 161 contract nonces do start at 0. You are probably passing in your address instead of the contract's address to web3.eth.getTransactionCount (or the contract you passed in did create another contract).

Here's an example of a contract that has a nonce of 0.

> web3.eth.getTransactionCount('0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.