getTransactionConfirmations
Returns the number of blocks passed (confirmations) since the transaction was processed on a block.
Usage
ts
import { publicClient } from './client'
const transactionReceipt = await publicClient.getTransactionReceipt({ hash: '...' })
const confirmations = await publicClient.getTransactionConfirmations({
transactionReceipt
})
// 15n
ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http()
})
You can also fetch confirmations by Transaction hash:
ts
import { publicClient } from './client'
const confirmations = await publicClient.getTransactionConfirmations({
hash: '0x...'
})
// 15n
ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http()
})
Returns
bigint
The number of blocks passed since the transaction was processed. If confirmations is 0
, then the Transaction has not been confirmed & processed yet.
Parameters
transactionReceipt
- Type:
TransactionReceipt
The transaction receipt.
ts
const balance = await publicClient.getTransactionConfirmations({
transactionReceipt: { ... },
})
hash
- Type:
Hash
The hash of the transaction.
ts
const balance = await publicClient.getTransactionConfirmations({
hash: '0x...'
})
Example
Check out the usage of getTransactionConfirmations
in the live Fetching Transactions Example below.