erc20_balance
Returns balance of the account address.
You can specify the contract address and account address, then you can obtain all the balance of that erc20 token which the account address has. If you don't specify the account address, the API can return all the balance in that contract. If you don't specify the contract address, the API can return all the balance associated with that account.
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 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
}
}'

Result

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"value": "7137577779588993946"
}
}
Copy link
Outline
Parameters
Returns
Example
Request
Result