2

I'm working on a project where I would like to catch internal transactions and figure out the stack trace. For this reason, I have been trying to define an EVM log collector as recommended here. Unfortunately that answer is 4 years old and EtherQuery library is no longer maintained. My code is the following:

snaps, statedb := MakePreState(rawdb.NewMemoryDatabase(), map[common.Address]core.GenesisAccount{}, true)
preRoot := statedb.IntermediateRoot(false)
defer func() {
    if _, err := snaps.Journal(preRoot); err != nil {
        panic(err)
    }
}()

var tracer *tracers.Tracer
tracer, err := tracers.New("callTracer")
if err != nil { panic(err) }

vmCfg := vm.Config{ Debug: true, Tracer: tracer, NoRecursion: true }
env := vm.NewEVM(vm.Context{BlockNumber: big.NewInt(1)}, statedb, params.TestChainConfig, vmCfg)

contract := vm.NewContract(account{}, account{}, big.NewInt(0), 10000)
contract.Code = []byte{byte(vm.PUSH1), 0x1, byte(vm.PUSH1), 0x1, 0x0}

_, err = env.Interpreter().Run(contract, []byte{}, false)
if err != nil { panic(err) }
fmt.Println(tracer.GetResult())

After running this snippet, I get the following:

[] TypeError: cannot read property 'toString' of undefined    in server-side tracer function 'result'

How should I set up the tracer? Thanks!

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.