1.9 KiB

title, description
title description
useBalance Primitive for fetching native currency balance.

useBalance

Primitive for fetching native currency balance.

Import

import { useBalance } from '@wagmi/solid'

Usage

::: code-group

import { useBalance } from '@wagmi/solid'

function App() {
  const balance = useBalance(() => ({
    address: '0x4557B18E779944BFE9d78A672452331C186a9f48',
  }))
}

<<< @/snippets/solid/config.ts[config.ts] :::

Parameters

import { useBalance } from '@wagmi/solid'

useBalance.Parameters
useBalance.SolidParameters

Parameters are passed as a getter function to maintain Solid reactivity.

useBalance(() => ({
  address: '0x...',
  // other parameters...
}))

address

Address | undefined

Address to get balance for. enabled set to false if address is undefined.

blockNumber

bigint | undefined

Block number to get balance at.

blockTag

'latest' | 'earliest' | 'pending' | 'safe' | 'finalized' | undefined

Block tag to get balance at.

chainId

config['chains'][number]['id'] | undefined

ID of chain to use when fetching data.

config

Config | undefined

Config to use instead of retrieving from the nearest WagmiProvider.

scopeKey

string | undefined

Scopes the cache to a given context. Primitives that have identical context will share the same cache.

Return Type

import { useBalance } from '@wagmi/solid'

useBalance.ReturnType

Action