Links

erc20_balance

Get the balance of the account address.
Through erc20_balance, you can fetch all the balance of that erc20 token which the account address has, contractAddress and accountAddress are necessary.
Supported on Ethereum, Optimism, and Arbitrum.

Parameters

Object - An object with the following fields (required):
  • contractAddress(hex string, required) - the contract address for ERC20 token.
  • accountAddress(hex string, required) - the account address you want to query.
  • blockNumber(integer number, optional) - the blockNumber for snapshot query (default latest). BlockVision can not only support users to query the current information, but also support users to query the historical information at any time.

Returns

Object - An object with the following fields:
  • id(integer number) - json-rpc id.
  • jsonrpc(string) - json-rpc version.
  • result(object) - an object with the following fields:
    • value(string) - balance value.

Example

Request

curl
TypeScript
curl https://api.blockvision.org/v1/<api key> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"id": 1,
"jsonrpc": "2.0",
"method": "erc20_balance",
"params": {
"contractAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"accountAddress":"0x02D436DC483f445f63Aac45b37db0eE661949842",
"blockNumber": 0
}
}'
import { BlockVisionProvider, BvNetwork } from 'blockvision.js'
// Optional parameters, but default to eth-mainnet and default api-key.
const bv = new BlockVisionProvider(BvNetwork.ETH_MAINNET)
// Access the BlockVision FT API
bv.getERC20Balance({
contractAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
accountAddress: '0x02D436DC483f445f63Aac45b37db0eE661949842'
}).then(console.log)

Result

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"value": "7137577779588993946"
}
}