getTransactionCount
Returns the number of Transactions an Account has broadcast / sent.
Import
ts
import { getTransactionCount } from 'viem'
Usage
ts
import { getTransactionCount } from 'viem'
import { publicClient } from '.'
const block = await getTransactionCount(publicClient, {
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
// 420
Returns
number
The number of transactions an account has sent.
Parameters
address
- Type:
'0x${string}'
The address of the account.
ts
const balance = await getTransactionCount(publicClient, {
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
blockNumber
- Type:
bigint
Get the count at a block number.
ts
const balance = await getTransactionCount(publicClient, {
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
blockNumber: 69420n
})
blockTag
- Type:
bigint
Get the count at a block tag.
ts
const balance = await getTransactionCount(publicClient, {
address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
blockTag: 'safe'
})
Notes
- The transaction count of an account can also be used as a nonce.