0

How get nonce of smart contract account with JSON RPC function? (Number of new smart contract accounts created by a smart contract account?)

eth_getTransactionCount only for EXTERNAL accounts so won't work right?

1

Why do you believe eth_getTransactionCount is only for externally owned accounts? In general, Ethereum differentiates very little between accounts with associated code (smart contracts) and externally owned accounts (EOA).

I believe eth_getTransactionCount will get you the correct nonce for any account. Note that smart contracts start with a nonce of 1 (read this for some nuance), so that's what you'll see for newly deployed contracts. So you may want to subtract 1 if you're actually wondering how many smart contracts a given contract has created.

  • I'm getting bogged down in the wording.....When a smart contract requests something from another smart contract, isn't that called a message? Transactions need digital signatures which smart contract messages do not have right? – Christian Seberino Jan 16 '18 at 19:54
  • That's correct. eth_getTransactionCount should probably be renamed eth_getNonce. :-) – user19510 Jan 16 '18 at 19:55
  • Wow that link you posted is really quite good. ;) And I see that another word for messages is "internal transactions" which makes everything clear now. Thanks for the help and the link! – Christian Seberino Jan 16 '18 at 19:58
  • The fact that nonce values for smart contracts accounts now start at 1 seems to imply the definition of nonces should be changed in the yellow paper now. They no longer always equal the number of previous transactions sent. – Christian Seberino Jan 16 '18 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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