private static FlatTrace.Context handleCreateOperation(
      final TraceFrame traceFrame,
      final Optional<TraceFrame> nextTraceFrame,
      final List<FlatTrace.Builder> flatTraces,
      final long cumulativeGasCost,
      final Deque<FlatTrace.Context> tracesContexts,
      final Optional<String> smartContractAddress) {
    final FlatTrace.Context lastContext = tracesContexts.peekLast();

    final String callingAddress = calculateCallingAddress(lastContext);

    final FlatTrace.Builder subTraceBuilder =
        FlatTrace.builder()
            .type("create")
            .traceAddress(calculateTraceAddress(tracesContexts))
            .resultBuilder(Result.builder());

    final Action.Builder subTraceActionBuilder =
        Action.builder()
            .from(smartContractAddress.orElse(callingAddress))
            .gas("0x" + Long.toHexString(computeGas(traceFrame, nextTraceFrame)))
            .value(Quantity.create(nextTraceFrame.map(TraceFrame::getValue).orElse(Wei.ZERO)));

    traceFrame
        .getMaybeCode()
        .map(Code::getBytes)
        .map(Bytes::toHexString)
        .ifPresent(subTraceActionBuilder::init);

    final FlatTrace.Context currentContext =
        new FlatTrace.Context(subTraceBuilder.actionBuilder(subTraceActionBuilder));

    currentContext
        .getBuilder()
        .getResultBuilder()
        .address(nextTraceFrame.map(TraceFrame::getRecipient).orElse(Address.ZERO).toHexString());
    currentContext.setCreateOp(true);
    currentContext.decGasUsed(cumulativeGasCost);
    tracesContexts.addLast(currentContext);
    flatTraces.add(currentContext.getBuilder());
    return currentContext;
  }
Generates a stream of {@link Trace} from the passed {@link TransactionTrace} and {@link Block}
data with additional Transaction Information added to FlatTrace

@param protocolSchedule the current {@link ProtocolSchedule} to use
@param transactionTrace the {@link TransactionTrace} to use
@param block the {@link Block} to use
@return a stream of generated traces {@link Trace}
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/tracing/flat/FlatTraceGenerator.java