diff --git a/eth/tracers/native/call_flat.go b/eth/tracers/native/call_flat.go index 9d7d2d96c8..43860f0af5 100644 --- a/eth/tracers/native/call_flat.go +++ b/eth/tracers/native/call_flat.go @@ -211,15 +211,18 @@ func (t *flatCallTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction } func (t *flatCallTracer) OnTxEnd(receipt *types.Receipt, err error) { - t.ctx = &tracers.Context{ - BlockHash: receipt.BlockHash, - BlockNumber: receipt.BlockNumber, - TxIndex: int(receipt.TransactionIndex), - TxHash: receipt.TxHash, - } if t.interrupt.Load() { return } + // Set the context for the tracer only if receipt is available and no error occured + if err == nil && receipt != nil { + t.ctx = &tracers.Context{ + BlockHash: receipt.BlockHash, + BlockNumber: receipt.BlockNumber, + TxIndex: int(receipt.TransactionIndex), + TxHash: receipt.TxHash, + } + } t.tracer.OnTxEnd(receipt, err) }