apibara / starknet-react

A collection of React providers and hooks for StarkNet
https://starknet-react.com
MIT License
369 stars 147 forks source link

Feat: Add a useBalance hook for ERC20s #241

Closed davelange closed 1 year ago

davelange commented 1 year ago

Closes #236

Add a useBalance hook, based on the wagmi equivalent, that fetches balance info for ERC 20 tokens.

const { data } = useBalance({
  address, // address to fetch balance for
  token, // token address, defaults to ETH token
  formatUnits // defaults to token decimals
})

Returns the original balance, formatted balance, symbol, and decimals:

Balance: {data.formatted} {data.symbol}
fracek commented 1 year ago

Looks good! Can you create a changelog entry with pnpm changeset? this one can be a patch change.

davelange commented 1 year ago

@fracek done

fracek commented 1 year ago

Thanks!

fracek commented 1 year ago

Also, contact me on telegram for the OnlyDust contribution.