4

I am trying to build a custom tracer, similar to these. To be specific, I am trying to add transaction hash info to call_tracer.js.

I have tried looking at Go code which initializes the tracers and checking every possible function call or property I could find, but I was unable to get the current transaction ID. Is this information even available to the tracer?

I am running code like this:

$ nc -U /opt/geth1.8/geth.ipc
{"id": 1, "method": "debug_subscribe", "params": ["traceChain", "0x6714a", "0x6714b", {"tracer": "{ step: function(log, db) {}, fault: function(log, db) {}, result: function(ctx, db) { return {ctx: ctx}; }, }"}]}

Tracer is an object which defines 3 functions, step, fault and result - my question is, how do I get current transaction hash in either step() or result()?

2 Answers 2

3

These are currently not available. It's something we'd like to add however.

1
  • Ah, that explains why I couldn't find it. It's a shame though, it could really help export all internal transactions, but without hash I can't use it in my case. Would it make sense to open an issue for this?
    – johndodo
    Commented Feb 20, 2018 at 12:45
2

If it helps someone: as @Péter Szilágyi said, it seems one can't get transaction hash directly from the tracer.

But - it can still be obtained via regular JSON RPC. So if you're after internal transactions, you can get them via tracer (use supplied call_tracer for instance) and fetch transaction hashes via JSON RPC call eth_getBlockByNumber (with second param set to true). Note that JSON RPC will give you the transactions in the block in the same order (which is order of execution).

Not ideal, but looks like it's still much faster than calling debug_traceTransaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.