You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`getTxReceipt` always resolves to one of three lifecycle variants of the `TxReceipt` union, depending on where the transaction is in its lifecycle:
72
72
73
-
-`status` - Transaction status (`pending`, `proposed`, `checkpointed`, `proven`, `finalized`, or `dropped`)
74
-
-`blockNumber` - Block where the transaction was included
75
-
-`transactionFee` - Fee paid for the transaction
76
-
-`error` - Error message if the transaction reverted
73
+
-`PendingTxReceipt` - still in the mempool. Exposes `status` (`pending`) and, when requested, the pending `tx`.
74
+
-`DroppedTxReceipt` - dropped by the node. Exposes `status` (`dropped`) and an optional `error` message.
75
+
-`MinedTxReceipt` - included in a block. Exposes `status` (`proposed`, `checkpointed`, `proven`, or `finalized`), `blockNumber`, `blockHash`, `txIndexInBlock`, `transactionFee`, and the execution result.
76
+
77
+
The `status`, `blockNumber`, and `transactionFee` fields are readable on the bare union, but block and fee details are only populated once the transaction is mined. Use the `isMined()`, `isPending()`, and `isDropped()` type guards to narrow to a specific variant before reading its fields:
78
+
79
+
```typescript
80
+
const receipt =awaitnode.getTxReceipt(txHash);
81
+
if (receipt.isMined()) {
82
+
console.log(`Mined in block ${receipt.blockNumber}, fee ${receipt.transactionFee}`);
83
+
}
84
+
```
85
+
86
+
You can pass a second `options` argument to attach extra data to the receipt:
87
+
88
+
-`includeTxEffect` - attaches the full `TxEffect` (note hashes, nullifiers, logs, and messages) to a mined receipt, available as `receipt.txEffect`.
89
+
-`includePendingTx` - attaches the pending `Tx` to a pending receipt, available as `receipt.tx`.
90
+
-`includeProof` - keeps the proof on that attached pending tx (only meaningful together with `includePendingTx`; the proof is stripped by default to avoid shipping large payloads over RPC).
91
+
92
+
For example, to read a mined transaction's effects, request them with `includeTxEffect` and read `receipt.txEffect` after narrowing with `isMined()`:
0 commit comments