public Optional<TransactionReceiptWithMetadata> transactionReceiptByTransactionHash(
      final Hash transactionHash, final ProtocolSchedule protocolSchedule) {
    final Optional<TransactionLocation> maybeLocation =
        blockchain.getTransactionLocation(transactionHash);
    if (maybeLocation.isEmpty()) {
      return Optional.empty();
    }
    // getTransactionLocation should not return if the TX or block doesn't exist, so throwing
    // on a missing optional is appropriate.
    final TransactionLocation location = maybeLocation.get();
    final Hash blockhash = location.getBlockHash();
    final int transactionIndex = location.getTransactionIndex();

    final Block block = blockchain.getBlockByHash(blockhash).orElseThrow();
    final Transaction transaction = block.getBody().getTransactions().get(transactionIndex);

    final BlockHeader header = block.getHeader();
    final List<TransactionReceipt> transactionReceipts =
        blockchain.getTxReceipts(blockhash).orElseThrow();
    final TransactionReceipt transactionReceipt = transactionReceipts.get(transactionIndex);

    long gasUsed = transactionReceipt.getCumulativeGasUsed();
    int logIndexOffset = 0;
    if (transactionIndex > 0) {
      gasUsed -= transactionReceipts.get(transactionIndex - 1).getCumulativeGasUsed();
      logIndexOffset =
          IntStream.range(0, transactionIndex)
              .map(i -> transactionReceipts.get(i).getLogsList().size())
              .sum();
    }

    Optional<Long> maybeBlobGasUsed =
        getBlobGasUsed(transaction, protocolSchedule.getByBlockHeader(header));

    Optional<Wei> maybeBlobGasPrice =
        getBlobGasPrice(transaction, header, protocolSchedule.getByBlockHeader(header));

    return Optional.of(
        TransactionReceiptWithMetadata.create(
            transactionReceipt,
            transaction,
            transactionHash,
            transactionIndex,
            gasUsed,
            header.getBaseFee(),
            blockhash,
            header.getNumber(),
            maybeBlobGasUsed,
            maybeBlobGasPrice,
            logIndexOffset));
  }
Returns the transaction receipt associated with the given transaction hash.

@param transactionHash The hash of the transaction that corresponds to the receipt to retrieve.
@return The transaction receipt associated with the referenced transaction.
ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/query/BlockchainQueries.java