ERC20 Balance

Fork me on GitHub

Rendered

Live demos require a web3 client. We recommend installing Metamask. Live demos require an unlocked web3 client. Please unlock your client.

<or-web3>
  Your MBGN Balance is: <b><or-erc20-balance token="0xdde19c145c1ee51b48f7a28e8df125da0cc440be" round="2"></or-erc20-balance></b>
</or-web3>

Installation

yarn add @openrelay/erc20-balance

Description

The <or-erc20-balance> element displays the user’s balance of a given ERC20 token.

API

HTML Attributes
  • token (required) — The token contract to display the balance of.
  • account [default=web3 default account] — The account to display the balance of.
  • refresh [default=true] — Whether to refresh the balance on block updates.
  • round [default=10] — The number of decimal places to display.
JavaScript Properties
  • value — A BigNumber object representing the token balance, adjusted based on the number of decimals for the token (not in base units).
  • balancePromise — A promise that resolves after this token’s balance has been retrieved from the blockchain.