Skip to content
LogoLogo

getTransactionConfirmations

Returns the number of blocks passed (confirmations) since the transaction was processed on a block.

Usage

// @filename: client.ts
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
 
export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
// @filename: example.ts
// ---cut---
import { publicClient } from './client'
 
const transactionReceipt = await publicClient.getTransactionReceipt({ hash: '...' })
const confirmations = await publicClient.getTransactionConfirmations({  
  transactionReceipt
})
// 15n

You can also fetch confirmations by Transaction hash:

import {  } from './client'
 
const  = await .({  
  : '0x...'
})
 
15n

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

The transaction receipt.

const  = await .({
  : { ... }, 
})

hash

The hash of the transaction.

const  = await .({
  : '0x...'
})

Example

Check out the usage of getTransactionConfirmations in the live Fetching Transactions Example below.

JSON-RPC Method

eth_getTransactionConfirmations