Skip to content

Instantly share code, notes, and snippets.

@glitch003
Last active January 23, 2019 10:43
Show Gist options
  • Save glitch003/03809eadc32d33f2fc2c7330645d65b9 to your computer and use it in GitHub Desktop.
Save glitch003/03809eadc32d33f2fc2c7330645d65b9 to your computer and use it in GitHub Desktop.
Use this to debug a ropsten TXN
// Try this first: http://s3.amazonaws.com/deco.network/debug/index.html
// first, paste in this
let txHash = '0x985ab562c4d6ea058f93f5118e4dc80110bbef534ce278a911e249a93aa18327'
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.0.0-beta.37/dist/web3.min.js';
document.head.appendChild(script);
// wait for script to append and load, then paste in below for either geth or parity
// FOR GETH
const web3WithDebug = new Web3('http://ropsten.eth.deco.network:8545')
web3WithDebug.currentProvider.send({
jsonrpc: "2.0",
method: "debug_traceTransaction",
id: new Date().getTime(),
"params":[txHash]
}, function (err, resp) {
if (err) {
console.error(err);
return
}
const { result } = resp
console.log('result: ',result)
const { returnValue } = result
console.log('return value: '+returnValue)
const message = Web3.utils.hexToUtf8('0x' + returnValue.substr(136))
console.log('Message: '+message)
}
)
// FOR PARITY
let web3WithDebug = new Web3('http://34.73.70.51:8545')
web3WithDebug.currentProvider.send({
jsonrpc: "2.0",
method: "trace_replayTransaction",
id: new Date().getTime(),
"params":[txHash, ["trace"]]
}, function (err, resp) {
if (resp.error) {
console.error(resp.error);
return
}
const { result } = resp
console.log('result: ',result)
const { output } = result
console.log('output: ',output)
const message = Web3.utils.hexToUtf8('0x' + output.substr(138))
console.log('Message: '+message)
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment