Skip to content

Commit 255336e

Browse files
authored
Add docs for useFlowTransaction (#1345)
Co-authored-by: Chase Fleming <1666730+chasefleming@users.noreply.github.com>
1 parent dcd2f2d commit 255336e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/tools/kit/index.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ sidebar_position: 1
2020
- [`useFlowQueryRaw`](#useflowqueryraw) – Execute Cadence scripts with optional arguments returning non-decoded data
2121
- [`useFlowMutate`](#useflowmutate) – Send transactions to the Flow blockchain
2222
- [`useFlowRevertibleRandom`](#useflowrevertiblerandom) – Generate pseudorandom values tied to block height
23+
- [`useFlowTransaction`](#useflowtransaction) – Fetch a Flow transaction by ID
2324
- [`useFlowTransactionStatus`](#useflowtransactionstatus) – Track transaction status updates
2425

2526
### Cross-VM (Flow EVM ↔ Cadence) Hooks
@@ -470,6 +471,45 @@ function RandomValues() {
470471

471472
---
472473

474+
### `useFlowTransaction`
475+
476+
```tsx
477+
import { useFlowTransaction } from "@onflow/kit"
478+
```
479+
480+
Fetches a Flow transaction by ID and returns the decoded transaction object.
481+
482+
#### Parameters:
483+
484+
* `txId?: string` – The Flow transaction ID to fetch.
485+
* `query?: Omit<UseQueryOptions<Transaction | null, Error>, "queryKey" | "queryFn">` – Optional TanStack Query options like `staleTime`, `enabled`, etc.
486+
487+
#### Returns: `UseQueryResult<Transaction | null, Error>`
488+
489+
```tsx
490+
function TransactionDetails({ txId }: { txId: string }) {
491+
const { data: transaction, isLoading, error, refetch } = useFlowTransaction({
492+
txId,
493+
query: { staleTime: 10000 },
494+
})
495+
496+
if (isLoading) return <p>Loading transaction...</p>
497+
if (error) return <p>Error fetching transaction: {error.message}</p>
498+
if (!transaction) return <p>No transaction data.</p>
499+
500+
return (
501+
<div>
502+
<h2>Transaction ID: {transaction.id}</h2>
503+
<p>Gas Limit: {transaction.gasLimit}</p>
504+
<pre>Arguments: {JSON.stringify(transaction.arguments, null, 2)}</pre>
505+
<button onClick={refetch}>Refetch</button>
506+
</div>
507+
)
508+
}
509+
```
510+
511+
---
512+
473513
### `useFlowTransactionStatus`
474514

475515
```tsx

0 commit comments

Comments
 (0)