otterscan/cmd/otter/commands/otterscan_trace_contract_cr...

51 lines
962 B
Go
Raw Normal View History

2022-10-25 01:58:24 +00:00
package commands
import (
"context"
"math/big"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/vm"
)
type CreateTracer struct {
DefaultTracer
ctx context.Context
target common.Address
found bool
Creator common.Address
Tx types.Transaction
}
func NewCreateTracer(ctx context.Context, target common.Address) *CreateTracer {
return &CreateTracer{
ctx: ctx,
target: target,
found: false,
}
}
func (t *CreateTracer) SetTransaction(tx types.Transaction) {
t.Tx = tx
}
func (t *CreateTracer) Found() bool {
return t.found
}
func (t *CreateTracer) CaptureStart(env *vm.EVM, depth int, from common.Address, to common.Address, precompile bool, create bool, calltype vm.CallType, input []byte, gas uint64, value *big.Int, code []byte) {
if t.found {
return
}
if !create {
return
}
if to != t.target {
return
}
t.found = true
t.Creator = from
}