File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 2626import org .hyperledger .besu .ethereum .core .BlockHeader ;
2727import org .hyperledger .besu .ethereum .core .LogWithMetadata ;
2828import org .hyperledger .besu .ethereum .core .Transaction ;
29+ import org .hyperledger .besu .ethereum .core .TransactionReceipt ;
2930import org .hyperledger .besu .ethereum .mainnet .ProtocolSchedule ;
3031import org .hyperledger .besu .ethereum .rlp .BytesValueRLPOutput ;
3132
@@ -292,6 +293,23 @@ public Optional<Long> getStatus(final DataFetchingEnvironment environment) {
292293 : Optional .of ((long ) receipt .getStatus ()));
293294 }
294295
296+ /**
297+ * Retrieves the revert reason of the transaction, if any.
298+ *
299+ * <p>This method uses the getReceipt method to get the receipt of the transaction. It then checks
300+ * the revert reason of the receipt. It would be an empty Optional for successful transactions.
301+ * Otherwise, it returns an Optional containing the revert reason.
302+ *
303+ * @param environment the data fetching environment.
304+ * @return an Optional containing a Bytes object representing the revert reason of the
305+ * transaction, or an empty Optional .
306+ */
307+ public Optional <Bytes > getRevertReason (final DataFetchingEnvironment environment ) {
308+ return getReceipt (environment )
309+ .map (TransactionReceiptWithMetadata ::getReceipt )
310+ .flatMap (TransactionReceipt ::getRevertReason );
311+ }
312+
295313 /**
296314 * Retrieves the gas used by the transaction.
297315 *
Original file line number Diff line number Diff line change @@ -579,6 +579,9 @@ type Transaction {
579579 BlobVersionedHashes is a set of hash outputs from the blobs in the transaction.
580580 """
581581 blobVersionedHashes : [Bytes32 ! ]
582+
583+ """Reason returned when transaction fails."""
584+ revertReason : Bytes
582585}
583586
584587"""EIP-4895"""
You can’t perform that action at this time.
0 commit comments