7

Simple question, but I couldn’t find the answer in the yellow paper.

Is it reset to 0 or is it kept at the latest value before destruction ?

user2284570
  • 1,008
  • 1
  • 12
  • 30

2 Answers2

7

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 example take this contract : https://etherscan.io/address/0x45bdac52403cf49f5e45bcb8b3ce71cf5f16ef14.

It has been destroyed at this transaction : https://etherscan.io/tx/0xffd55f831d443ac45c33fb22e1bc2c24a7de49e10c9bf2251a4e0e77b5940ed4.

We get the account nonce with web3js this way :

const nonce = await web3.eth.getTransactionCount("0x45bdac52403cf49f5e45bcb8b3ce71cf5f16ef14");
console.log("nonce : ",nonce); 

It returns us 0.

clement
  • 4,302
  • 2
  • 17
  • 35
-1

Ethereum addresses with a codesize > 0 should always have a nonce of zero, as the address it sits at is created deterministically from the transaction that adds the code (creates the contract), and not from a private key. Thus the contract itself can never make transactions and its nonce can never be increased.

Nonces only increase with addresses that can make (sign) transactions

Zakalwe
  • 397
  • 1
  • 4
  • 7
    Incorrect. Contract addresses start with a nonce of 1 since EIP 160. Additionally the contract nonce is incremented each time it creates another contract (ref: yellow paper). – Chan-Ho Suh Oct 05 '19 at 14:34