getBalance
Returns the balance of an address in wei.
Usage
import { } from './client'
const = await .getBalance({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})
> 10000000000000000000000n (wei)Returns
bigint
The balance of the address in wei.
Parameters
address
- Type:
Address
The address of the account.
const = await .getBalance({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})blockNumber (optional)
- Type:
bigint
The balance of the account at a block number.
const = await .getBalance({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
: 69420n
})blockTag (optional)
- Type:
'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
The balance of the account at a block tag.
const = await .getBalance({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
: 'safe'
})Tips
- You can convert the balance to ether units with
formatEther.
import { } from 'viem'
const = await .getBalance({
: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
: 'safe'
})
const = ()
// "6.942"