//Just getting the requirements
var Trie = require('merkle-patricia-tree/secure');
var levelup = require('levelup');
var leveldown = require('leveldown');
var RLP = require('rlp');
var assert = require('assert');
var VM = require('ethereumjs-vm')
var Account = require('ethereumjs-account')
//Connecting to the leveldb database
var db = levelup(leveldown('/home/tp/gethDataDir/geth/chaindata'));
//Adding the "stateRoot" value from the block so that we can inspect the state root at that block height.
var root = '0x9369577baeb7c4e971ebe76f5d5daddba44c2aa42193248245cf686d20a73028';
//Creating a trie object of the merkle-patricia-tree library
var trie = new Trie(db, root);
//Trying new code from ethereumjs
var address = '0x9b3d09e19739d47817dfa5a2462656a028099854';
trie.get(address, function (err, raw) {
if (err) return cb(err)
var account = new Account(raw)
var exists = !!raw
account.exists = exists
console.log(account.balance.toString());
console.log(RLP.decode(account.balance,[skipRemainderCheck=false]));
})
Created
February 5, 2018 01:06
-
-
Save tpmccallum/2fac7a261fc39cb06cbdf68e088db750 to your computer and use it in GitHub Desktop.
Ethereum Account Balance
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment