Links

erc20_approvals

Get the history of ERC20 approval events for any address without scanning the entire chain.
If you specify the contract address and account address, the API will return all the transfer events of that collection which the account address has. If you only specify the contract address, the API will return all the approval events happening in that contract. If you only specify the contract address, the API will return all the approval events associated with that account.
Supported on Ethereum, BNB Chain, Optimism, and Arbitrum.

Parameters

Object - An object with the following fields (required):
  • accountAddress(hex string, optional) - the account address to filter for.
  • contractAddress(hex string, optional) - the ERC20 contact address to filter for.
  • 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.
  • fromAddress(hex string, optional) - the sending address in the transaction.
  • toAddress(hex string, optional) - the receiving address in the transaction.
  • 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:
    • value(string) - approval amount.
    • contractAddress(hex string) - the address for the ERC20 contract.
    • blockNumber(integer number) - the block that the transaction was included in.
    • txHash(hex string) - the hash code for the transaction.
    • blockHash(hex string) - the hash code for the block.
    • logIndex(integer number) - the index number for the log.
    • removed(boolean) - is approval removed.
    • owner(hex string) - the address of the owner.
    • spender(hex string) - the address of the spender.

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_approvals",
"params": {
"fromBlockNumber": 0,
"toBlockNumber": 100000000,
"fromAddress":"0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"toAddress":"",
"contractAddress":"0x383518188C0C6d7730D91b2c03a03C837814a899",
"pageSize": 100,
"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.getERC20Approvals({}).then(console.log)

Result

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"data": [
{
"value": "115792089237316195423570985008687907853269984665640564039457584007885614472378",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13681768,
"txHash": "0x20d3315cce236fc2c8f54fa0291043ad7453599231cb217286cb10c9c060c23c",
"blockHash": "0x79f2b6a015c283a1ccfeeb0f4d2291bba9702acfb5a18cbaa2f3fd0266cf0eb9",
"logIndex": 372,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007889121450735",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13550183,
"txHash": "0x1a9398f30f0d1b5057528eb9f3fd06c9781dbb8bfb23a82b0a2f6ed69a6ec0b6",
"blockHash": "0xc5b31974726d369731082cbc3a28c3dafc823bb37ce5223a0afc384b7e30be4a",
"logIndex": 255,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007894121450735",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13504429,
"txHash": "0x09207e28cfe69627d97eecefb38fd558dac3cda9c1eb224880387880c210d12a",
"blockHash": "0x3d6a02a23d8f619545eae2e3ddef7301130f83c01319cd6438820b42c7d4f29a",
"logIndex": 455,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007901537439935",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13500914,
"txHash": "0x4a8765bf24bb0fa01235fac96214e64615be86b2afa945fa72c20b133a85deb2",
"blockHash": "0x98f0ea863bd9a21213454341b8ccf2faa88a89dfeec0c90e24ca82b2d9fb2810",
"logIndex": 342,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007905198639935",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13476336,
"txHash": "0xfae8b745c9c6f391a91fd1f3d7895e319236351fd2021d5a9b55650514c7032f",
"blockHash": "0x9292fea3d3bb49e1189fb7ace2a816fcd96e46927e1a8d74350e9ffc261a64f2",
"logIndex": 77,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007906198639935",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13471864,
"txHash": "0x6955915ed2d63bb43670f751e9d653ea3edd57dfc7cd2781539ad527b48eb624",
"blockHash": "0x6b7b1dddf3ba4225346a1b7d0316aa14166e1c6fc97c310a43786ab198a6f329",
"logIndex": 172,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007907898639935",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 13451664,
"txHash": "0x5ff5ad68dac207423c5d90feccda99dbe071c434bb7bda09beab0c8c20929810",
"blockHash": "0x60ed54de9cb12bc48a068860b54c6175138dbadb776c1a5b36be464b685f385e",
"logIndex": 371,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 12699186,
"txHash": "0x7cdbe021ac80b39adc4ed6214d8ef56f8ba1775f9f9c7e48365ae881428bed92",
"blockHash": "0xae6f91b3234371d1aa300df6e1756f7f30f67bd9dde921919b0a4e1c9522ab02",
"logIndex": 165,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
},
{
"value": "115792089237316195423570985008687907853269984665640564039457584007909898639935",
"contractAddress": "0x383518188C0C6d7730D91b2c03a03C837814a899",
"blockNumber": 12699186,
"txHash": "0x7cdbe021ac80b39adc4ed6214d8ef56f8ba1775f9f9c7e48365ae881428bed92",
"blockHash": "0xae6f91b3234371d1aa300df6e1756f7f30f67bd9dde921919b0a4e1c9522ab02",
"logIndex": 167,
"removed": false,
"owner": "0xe34B087Bf3C99E664316A15B01E5295eB3512760",
"spender": "0xDef1C0ded9bec7F1a1670819833240f027b25EfF"
}
],
"nextPageIndex": 1
}
}