Links

erc20_balanceChangedList

Get the historical balance for any address without scanning the entire chain.
Through erc20_balanceChangedList, you can fetch the historical balance for any address, contractAddress and accountAddress are necessary. If you don't specify the block number, the API will return all the the changed balance for the account address order by block number desc.
Supported on Ethereum.

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.
  • fromBlockNumber(integer number, optional) - the starting time range you want to fetch events over.
  • toBlockNumber(integer number, optional) - the ending time range you want to fetch events over.
  • pageSize(integer number, optional, default 100) - max number of results to return per call.
  • pageIndex(integer number, optional, default 1) - page index.

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:
    • nextPageIndex(integer number) - next page (if exists, else blank).
    • data(array of object, defined below) - response data, sorted in ascending order by block number.
  • Object schema:
    • blockNumber(integer number) - the block that the transaction was included in.
    • value(string) - balance value (the unit is wei).

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_balanceChangedList",
"params": {
"contractAddress":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"accountAddress":"0x02D436DC483f445f63Aac45b37db0eE661949842",
"pageSize": 3,
"pageIndex": 1
}
}'
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.getERC20BalanceChangedList({
contractAddress: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
accountAddress: '0x02D436DC483f445f63Aac45b37db0eE661949842'
}).then(console.log)

Result

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"data": [
{
"contractAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"accountAddress": "0x02D436DC483f445f63Aac45b37db0eE661949842",
"blockNumber": 15530802,
"value": "6489858594957524535"
},
{
"contractAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"accountAddress": "0x02D436DC483f445f63Aac45b37db0eE661949842",
"blockNumber": 15527693,
"value": "6419858594957524535"
},
{
"contractAddress": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"accountAddress": "0x02D436DC483f445f63Aac45b37db0eE661949842",
"blockNumber": 15515260,
"value": "6270108594957524535"
}
],
"nextPageIndex": 2
}
}