Skip to content

Instantly share code, notes, and snippets.

View sontuphan's full-sized avatar

Phan Sơn Tự sontuphan

  • Ho Chi Minh City University of Technology (Bach Khoa)
  • Ho Chi Minh City
View GitHub Profile
{
do: 0,
dog: 1,
dax: 2,
dogu: 3,
dodo: 4,
house: 5,
houses: 6
}
{
'cab8': 'dog',
'cabe': 'cat',
'39': 'chicken',
'395': 'duck',
'56f0': 'horse'
}
@sontuphan
sontuphan / geth.js
Last active February 23, 2018 08:33
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log("\n===========================================");
console.log("========== Geth connected:", web3.isConnected(), "===========");
console.log("===========================================\n");
var Geth = function () {}
Geth.getStateRoot = function (blockNumber) {
var path = require('path');
var levelup = require('levelup');
var leveldown = require('leveldown');
/**
* Level DB
*/
var levelDBPath = path.relative('./', '/Users/User/Library/Ethereum/ropsten/geth/chaindata');
var db = levelup(leveldown(levelDBPath));
var merklePatriciaTree = require('merkle-patricia-tree');
var rlp = require('rlp');
var db = global.db;
var Trie = function () {}
Trie.getInfoByAddress = function (root, address) {
var root = new Buffer(root, 'hex');
var address = new Buffer(address, 'hex');
var trie = new merklePatriciaTree(db, root);
var db = global.db;
var ethBlock = require('ethereumjs-block');
var rlp = require('rlp');
var utils = require('./libs/utils');
var geth = require('./libs/geth');
var trie = require('./libs/trie');