2

I am creating a wrapper for monitoring the transaction of accounts. I am able to trace the transaction which happens between two accounts, whereas if it happens through a smart contract, I cant able to trace it. In etherscan, I can see it in an internal transaction. How to trace the internal transaction in Javascript?

2

Parity provides a very nice eth_tracetransaction RPC command (and related calls). This is the only way I know to get the traces. "Internal Transactions" are just a smart contract calling into another smart contract. This data is found in the traces. Note, Geth provides traces, but they're not as easy to use as Parity.

2
1

The internal transactions can be traced using trace module available in ethereum clients. Other than that, there are more options:

  • Etherscanner is another tool which you can use to find internal transactions.
  • Etherquery uploads all ethereum data to bigquery and it also has mechanism to track internal transactions.
  • Parity-trace_call and Geth-tracers introduce mechanisms which replay the transactions and return those calls which move ethers.

The PR in geth introducing tracers allows anyone to introduce their own custom tracers written in either go or js. You can call those methods in following manner using web3@0.20

var web3 = require('web3');
web3.web3.currentProvider.sendAsync({
    method: "debug_traceTransaction",
    params: ['0x3fac854179691e377fc1aa180b71a4033b6bb3bde2a7ef00bc8e78f849ad356e', {}],
    jsonrpc: "2.0",
    id: "2"
}, function (err, result) {
    ...
});
1

Your two main options for tracing internal transactions in JS are (a) running a Parity node (which can be super expensive and take up to several weeks to sync) or (b) using address activity tracking (such as internal transactions) from Alchemy Notify.

I'd highly recommend checking out Alchemy Notify-- it was free, and I was up and running in less than 5 minutes. Here's a link to their docs: https://docs.alchemyapi.io/alchemy/guides/using-webhooks#address-activity

Hope that helps :)

0

There are some web3js forks implemented trace modules for Parity, e.g. this one https://github.com/BitySA/web3.js/commits/develop:

function Trace(web3) {
    this._requestManager = web3._requestManager;

    var self = this;

    methods().forEach(function(method) {
        method.attachToObject(self);
        method.setRequestManager(self._requestManager);
    });
}

However, it only supports Parity instead of Geth. Later tracing support from within Geth is different from this method which leads to confusion and incompatibilities.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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