4

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?

  • you can use a private network or a remix IDE's JavaScript VM? – Achala Dissanayake May 9 at 15:00
4
+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

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?

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

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.