docs ⦿ dedot 🧑‍💻
DedotXTelegramGithub
typink ✏️
typink ✏️
  • Welcome to Typink
  • Introducing Typink
  • Getting started
    • Start a new dapp
    • Migrate from existing dapp
    • Supported networks
  • create-typink CLI
  • Hooks & Providers
    • TypinkProvider
    • useTypink
    • useContract
    • useContractQuery
    • useContractTx
    • useDeployer & useDeployerTx
    • useWatchContractEvent
    • useBalance & useBalances
    • usePSP22Balance
  • Utilities
    • formatBalance
    • txToaster
    • dedot/utils
  • HELP & FAQ
    • Tutorials
      • Develop ink! dApp using Typink
  • Telegram
  • Github
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Hooks & Providers

usePSP22Balance

The usePSP22Balance hook retrieves an account’s balance on a PSP22 contract. The hook also comes with a watch mode to continuously monitor balance changes, updating the value in real time.

Usage

import { usePSP22Balance, useTypink } from 'typink';

// ...
const { connectedAccount } = useTypink();
const psp22ContractAddress = '...'

const {
    data: myPsp22Balance,
    isLoading,
    refresh,
    // ...
  } = usePSP22Balance({
    contractAddress: psp22ContractAddress,
    address: connectedAccount?.address,
    watch: true
  });
  
// ...

PrevioususeBalance & useBalancesNextUtilities

Last updated 3 months ago

Was this helpful?