ethstatedb
v1.0.8
Published
Command to check Ethereum state database
Downloads
9
Readme
ethstatedb
Command to check Ethereum state database
This cli is created when I was studying Ethereum. I was curious about when and how an accout is created and maintained by Ethereum state database. From Diving into Ethereum's world state, it explains that accounts are not created in state database until there is a transaction for it. So I create this small tool to verify it.
Usage
$ npm install -g ethstatedb
$ ethstatedb account -d .db/chaindata/ -r 0xecc60e00b3fe5ce9f6e1a10e5469764daf51f1fe93c22ec3f9a7583a80357217 0x095e7baea6a6c7c4c2dfeb977efac326af552
Address 0x095e7baea6a6c7c4c2dfeb977efac326af552
Balance 0
Nonce 0
StateRoot
CodeHash
Commands
ethstatedb account [ADDRESS]
Retrieve account information from Ethereum state database
USAGE
$ ethstatedb account ADDRESS
ARGUMENTS
ADDRESS public key of an account, e.g.
0x7C476EA4e20D6d49820Ee810C0C474ED11b3f527
OPTIONS
-d, --dbdir=dbdir (required) path of Ethereum state database, e.g.
ethereum/geth/chaindata
-h, --help show CLI help
-r, --root=root (required) value of stateRoot
--skip-copy skip copying database to .ethstatedb. By default,
database is copied to avoid messing the original
database.
--work-dir=work-dir directory to pull down database
EXAMPLE
$ ethstatedb account --dbdir /home/data/ethereum-node1/geth/chaindata --root
0x595e3a0db7f38600770a267b12b67a8da1c202fef4b6c21e60fdb92477d89753
0x7C476EA4e20D6d49820Ee810C0C474ED11b3f527
ethstatedb help
Display help for ethstatedb
Command to check Ethereum state database
VERSION
ethstatedb/1.0.5 darwin-x64 node-v10.15.3
USAGE
$ ethstatedb [COMMAND]
COMMANDS
account load information of an account
help display help for ethstatedb
More information
- When playing with data generated by geth, make sure to stop geth so that it flushes all data to database. This command by default copies the data to a temp location, i.e.
.ethstatedb
, to avoid messing up the original database. However, you can use--skip-copy
to use original database. - To get stateRoot, use
geth attach ipc://path/to/geth.ipc
to connect to a node. Then useeth.getBlock(eth.blockNumber).stateRoot
to get stateRoot for the latest block. You can changeeth.blockNumber
to be number of the specific block that you are interested in.