You can show the balance of the primary wallet by using the useDynamicContext hook and the
getBalance
method from the wallet connector.React
getBalance
method from the wallet connector.import { useDynamicContext } from '@dynamic-labs/sdk-react-core'
const { primaryWallet } = useDynamicContext()
const [balance, setBalance] = useState(null)
useEffect(() => {
const fetchBalance = async () => {
if (primaryWallet) {
const value = await primaryWallet.getBalance()
setBalance(value)
}
}
fetchBalance()
}, [primaryWallet])
return <p>{balance}</p>
Was this page helpful?