0

Currently there is no way to check somehow that an account exists in the trie. I am looking for something like this:

> web3.eth.accountExist("0x743623152a53b53be5f3463746726373")
true
>

Is a function like this available in console?

Note, I want to check in the state trie (the StateDB database stored in LevelDB), not in the list of users' wallets.

1

There's no standard interface to access the Ethereum world state beyond getBalance, getTransactionCount (getStorageAt, getCode for contracts).

The state trie is kinda of low level concept and clients are free to choose any implementation to suit them best. You have to look at your particular client to determine how to access it.

1

This is a somewhat roundabout way to achieve what you want, but I don't believe there is a direct one.

An account will exist in the state trie if it has a non-zero balance (such as an externally owned account that has only received ether, without sending any out) or if it has a non-zero nonce (such as a externally owned account that has sent out all the ether it has received, or a contract account, since contract accounts always start with a nonce of 1).

You should be able to use a combination of eth_getBalance and eth_getTransactionCount to check if an account exists in the current trie.

1

Every possible account in an Ethereum network exists already. It maybe owned by zero or more parties but it exists regardless of the ownership.

What you want to know would be the usage info of a specific account. And you can check transaction count for this purpose.

  • 1
    no. maybe I wasn't clear enough, I want to know if the StateDB in the LevelDB database the account record exists. In other words, the node on the trie corresponding to the account data. – Nulik Sep 13 '18 at 14:26

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.