6

I am looking for a way to execute current pending transactions on local node, to see their outcome and log events, without really mine it.

it is some kind of pre-simulation, to see what is going to happen on the next block in the network.

is it possible? how can it be done?

1
  • you can use a private network or a remix IDE's JavaScript VM? May 9, 2019 at 15:00

2 Answers 2

5
+50

You can totally simulated the transaction througth eth_call.

Her are the code snippets of eth_call and apply transaction (source from go-ethereum):

eth_call (could not change state)

// Setup the gas pool (also for unmetered requests)
// and apply the message.
gp := new(core.GasPool).AddGas(math.MaxUint64)
res, gas, failed, err := core.ApplyMessage(evm, msg, gp)
if err := vmError(); err != nil {
    return nil, 0, false, err
}
return res, gas, failed, err

apply transaction (could update state)

_, gas, failed, err := ApplyMessage(vmenv, msg, gp)
if err != nil {
    return nil, 0, err
}
// Update the state with pending changes
var root []byte
if config.IsByzantium(header.Number) {
    statedb.Finalise(true)
} else {
    root = statedb.IntermediateRoot(config.IsEIP158(header.Number)).Bytes()
}

Remember to return the result of simulation when you use eth_call.

The solidity function looks like:

function simulation() pure public returns(bool result) {
    result = doSimulation();
}
2
2

The JSON_RPC eth_call method allows you to simulate a transaction on the blockchain, including contract executions.

From : How can I execute code locally at given address?

1
  • Thanks! thats help, is there a way to access the event logs that happens during the transaction call?
    – Or Bachar
    May 10, 2019 at 7:20

Your Answer

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

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