3

I am using infura.io as my node and trying to get the internal transactions (i.e. transfers initiated by smart contract) for a specific transaction (or its parent block). I have two attempts (both erroring out). It feels like I am missing something basic here.

Some setup code:

const Web3 = require("web3");
const VM = require('ethereumjs-vm');
const Tx = require('ethereumjs-tx');
const blockFromRpc = require('ethereumjs-block/from-rpc');
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/' + process.env.INFURA_API_KEY));

const vm = new VM();

When I try this:

web3.eth.getTransaction('0x6b871b7db60454cf97fe7b5d0bb1192f23984e35990dfeeb8df5b9295d0eaaf5')
    .then(tx => {
        web3.eth.getBlock(6189875)
            .then(block => {
                try {
                    vm.runTx({
                        tx: new Tx({
                            ...tx,
                            data: tx.input
                        }),
                        block: blockFromRpc(block)
                    }, function(err, results){
                        console.log('returned: ' + results.logs);
                    });
                }
                catch(e) {
                    const i = e;
                }
            });
    });

I get an error:

The sender does not have enough ether to send this tx

and when I try this:

web3.eth.getBlock(6189875)
    .then(block => {
        try {
            vm.runBlock({
                block: blockFromRpc(block),
                //block
            }, function(err, results){
                console.log('returned: ' + results.logs);
            });
        }
        catch(e) {
            const i = e;
        }
    });

I get an error:

base free exceeds gas limit

Whats going on? I just want to replay the transaction or block so that I can see the internal transactions.

Thanks in advance.

  • I don't know about Infura, but I have my solution to export all internal transactions from the blockchain. It exports everything into SQL DB. I have also got approvals and transfers in separate tables. Historic balances of the token accounts and other cool stuff. The code is in development right now , but If interested, leave your contract data and I will send it to you. – Nulik Aug 23 '18 at 17:45
  • @Nulik I don't really want to maintain an ethereum node. Do you know of any solution where I can use a remote node? – istrau2 Aug 23 '18 at 17:51
  • then you need a node that supports transaction tracing, sort of like this: ethereum.stackexchange.com/questions/9434/… , also I suggest checking Parity, maybe they have got more advanced on this subject. – Nulik Aug 23 '18 at 18:32
  • @Nulik I haven't been able to find one (infura doesn't as far as I know). Also, the issue is that I would probably be rate limited. On another note, I've seen GetModifiedAccountsByNumber floating around. Do you know of any way I could access that on a public node? – istrau2 Aug 23 '18 at 18:36
  • You need the functionality that appeared in geth 1.8 , callTracer blog.ethereum.org/2018/02/14/geth-1-8-iceberg%C2%B9 , it will give you internal transaction in an easy JSON array . GetModifiedAccountsByNumber is also part of the debug module which requies to be enabled by node administrator – Nulik Aug 23 '18 at 18:56

Your Answer

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

Browse other questions tagged or ask your own question.