public static Bytes encodeOpaqueBytes(
      final Transaction transaction, final EncodingContext encodingContext) {
    final TransactionType transactionType = getTransactionType(transaction);
    if (TransactionType.FRONTIER.equals(transactionType)) {
      return RLP.encode(rlpOutput -> FrontierTransactionEncoder.encode(transaction, rlpOutput));
    } else {
      final Encoder encoder = getEncoder(transactionType, encodingContext);
      final BytesValueRLPOutput out = new BytesValueRLPOutput();
      transaction
          .getRawRlp()
          .ifPresentOrElse(
              (rawRlp) ->
                  out.writeRLPBytes(
                      Bytes.concatenate(Bytes.of(transactionType.getSerializedType()), rawRlp)),
              () -> {
                out.writeByte(transaction.getType().getSerializedType());
                encoder.encode(transaction, out);
              });
      return out.encoded();
    }
  }
Encodes a transaction into opaque bytes.

@param transaction the transaction to encode
@param encodingContext the encoding context
@return the encoded transaction as bytes
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java