Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var fs = require('fs');
const createKeccakHash = require('keccak');
var jayson = require('jayson');
var transaction = "0x1066b9764832dc6dc710c3e131ee54c68c1b3f1e21de6b3dc8f97ee68ff3f190";
var client = jayson.client.http({
host: "149.248.8.23",
port: 8545,
});
function hash(value) {
let hasher = createKeccakHash('keccak256');
hasher.update(Buffer.from(value.join(""), "hex"));
return hasher.digest("hex").slice(0, 5);
}
function processStructLogs(logs) {
logs.map((log) => {
console.log(`${log.pc} ${log.op.padStart(8)} ${log.gas.toString().padStart(8)}`)
// console.log(hash(log.memory.join())
// Here is where you can inspect storage, memory, stack and the program counter
// If you want to quickly compare large chunks of data you can hash them
// console.log(log.storage)
// console.log(log.pc)
if(log.pc == 1202) {
console.log(log.memory.join(""));
}
})
}
// To pull directly from Geth
// https://github.com/ethereum/go-ethereum/wiki/Tracing:-Introduction
//
// client.request("debug_traceTransaction", [transaction], (err, logs) => {
// if (err) {
// console.log(err);
// } else {
// processStructLogs(logs);
// }
// });
// To pull from file
fs.readFile('0x1066b9-trace.json', 'utf8', (err, logs) => {
if (err) {
console.log(err);
} else {
processStructLogs(JSON.parse(logs.replace(/(['"])?([a-z0-9A-Z_]+)(['"])?:/g, '"$2": ')).structLogs)
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.