waitForTransaction
Waits until the transaction is processed, added to the block and indexed by the blockchain explorer.
Usage
import { publicClient } from './client';
const transaction = await publicClient.waitForTransaction({
hash: '0:123...',
});Returns
Transaction | undefined
The information about the transaction.
Parameters
hash
- Type:
string
Transaction hash. Returned by the sendTransaction method and others.
const transaction = await publicClient.waitForTransaction({
hash: '0:123...',
});refetchInterval (optional)
- Type:
number - Default:
1000
Configures how often the transaction is fetched.
const transaction = await publicClient.waitForTransaction({
hash: '0:123...',
refetchInterval: 5000,
});refetchLimit (optional)
- Type:
number - Default:
undefined
Set this parameter to limit the number of fetches. If the transaction is not found after the limit is reached, the method returns undefined.
const transaction = await publicClient.waitForTransaction({
hash: '0:123...',
refetchLimit: 5,
});