traceTransaction
debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.disableStorage
: BOOL
. Setting this to true will disable storage capture (default = false).disableMemory
: BOOL
. Setting this to true will disable memory capture (default = false).disableStack
: BOOL
. Setting this to true will disable stack capture (default = false).tracer
: STRING
. Setting this will enable JavaScript-based transaction tracing, described below. If set, the previous four arguments will be ignored.timeout
: STRING
. Overrides the default timeout of 5 seconds for JavaScript-based tracing calls. Valid values are described here.debug.TraceTransaction(txHash common.Hash, logger *vm.LogConfig) (*ExecutionResurt, error)
debug.traceTransaction(txHash, [options])
{"method": "debug_traceTransaction", "params": [txHash, {}]}
tracer
option in the second argument enables JavaScript-based tracing. In this mode, tracer
is interpreted as a JavaScript expression that is expected to evaluate to an object with (at least) two methods, named step
and result
.step
is a function that takes two arguments, log and db, and is called for each step of the EVM, or when an error occurs, as the specified transaction is traced.log
has the following fields:pc
: Number, the current program counterop
: Object, an OpCode object representing the current opcodegas
: Number, the amount of gas remaininggasPrice
: Number, the cost in wei of each unit of gasmemory
: Object, a structure representing the contract's memory spacestack
: array[big.Int], the EVM execution stackdepth
: The execution depthaccount
: The address of the account executing the current operationerr
: If an error occurred, information about the errorerr
is non-null, all other fields should be ignored.log
object is reused on each execution step, updated with current values; make sure to copy values you want to preserve beyond the current call. For instance, this step function will not work:log.op
has the following methods:isPush()
- returns true iff the opcode is a PUSHntoString()
- returns the string representation of the opcodetoNumber()
- returns the opcode's numberlog.memory
has the following methods:slice(start, stop)
- returns the specified segment of memory as a byte slicelength()
- returns the length of the memorylog.stack
has the following methods:peek(idx)
- returns the idx-th element from the top of the stack (0 is the topmost element) as a big.Intlength()
- returns the number of elements in the stackdb
has the following methods:getBalance(address)
- returns a big.Int
with the specified account's balancegetNonce(address)
- returns a Number with the specified account's noncegetCode(address)
- returns a byte slice with the code for the specified accountgetState(address, hash)
- returns the state value for the specified account and the specified hashexists(address)
- returns true if the specified address exists.String()
on them. For convenience, big.NewInt(x)
is provided, and will convert a uint to a Go BigInt.