getTokenApprovals

Get ERC20 approvals for a given token contract address

The "getTokenApprovals" method provides developers with a powerful tool to retrieve and access all approvals for a specified ERC20 token contract address. These approvals are presented in reverse chronological order, with the most recent approvals appearing first in the response. This documentation section offers comprehensive insights into the usage of the "getTokenApprovals" method, enabling developers to efficiently access and analyze approval events associated with the token contract.

How to use getTokenApprovals method ?

Below, you'll find an in-depth guide that provides a comprehensive explanation of how to utilize the getTokenApprovals Builder API method effectively using Blast.

Parameters

Below, you can find the query parameters accepted by the method.

FieldTypeDescription

contractAddress *

string

The token contract address

fromBlock

string

The block number from which the approvals will be returned

toBlock

string

The block number up to which the approvals will be returned

ownerAddress

string

The address of the approver

spenderAddress

string

The address of the spender

pageSize

integer

Number of records to be retrieved on one page

pageKey

string

Key used to get the next page of results. Must be set to the value of nextPageKey returned in the previous response

Returns

Discover an insightful explanation of the returned parameters here, offering a deep understanding of their significance and implications.

FieldTypeDescription

contractAddress

string

The token contract address

contractDecimals

string

Token decimals specified in the contract

contractName

string

The name of the token

contractSymbols

string

The symbol of the token

count

integer

The number of token approvals

nextPageKey

string

Key to get the next page of results, if more results are available

tokenApprovals

array

The array containing all token approvals

ownerAddress

string

The wallet address of the approver

spenderAddress

string

The address of the spender

value

string

The amount of tokens approved

blockHash

string

The hash of the block in which the transfer transaction was executed

blockNumber

integer

The height of the block in which the transfer transaction was executed

blockTimestamp

string

The timestamp of the block in which the transfer transaction was executed

transactionHash

string

The hash of the token transfer transaction

transactionIndex

integer

The number of the token transfer transaction

logIndex

integer

The index of the transaction log

Example Request and Result for getTokenApprovals

In this section, you'll find an illustrative example of a request made to retrieve token approvals using the getTokenApprovals method. This example showcases how to specify the required parameters and provides insights into the expected result structure. The example request demonstrates how to configure the parameters, including the contract address, owner address, and spender address, to narrow down the approvals you want to retrieve.Developers can refer to this section to understand how to use the method effectively and interpret the returned data.

The example in this section uses a non-existing project id.

Make sure you replace it with your Starknet endpoint when issuing the Builder API calls.

Don't have a project id? Here's a straightforward guide on how to obtain one!

Returns the ERC20 approvals for a given token contract address

GET https://starknet-mainnet.blastapi.io/<project_id>/builder/getTokenApprovals

Query Parameters

NameTypeDescription

contractAddress*

0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7

fromBlock

String

515018

ownerAddress

String

0x0373aa6e162d47f9f0c6304d4580a0fed41552283dbf9936f3606581a5a84f69

{
  "contractAddress": "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
  "contractDecimals": "18",
  "contractName": "Ether",
  "contractSymbol": "ETH",
  "count": 1,
  "tokenApprovals": [
    {
      "ownerAddress": "0x0373aa6e162d47f9f0c6304d4580a0fed41552283dbf9936f3606581a5a84f69",
      "spenderAddress": "0x057146f6409deb4c9fa12866915dd952aa07c1eb2752e451d7f3b042086bdeb8",
      "value": "5780000000000000",
      "blockHash": "0x0409bb9e5bf7c999d81ccd1fb23b44bb684068cd91a9e0df1cea27e12cfbef14",
      "blockNumber": 515018,
      "blockTimestamp": "2024-01-22T18:21:06.000Z",
      "transactionHash": "0x062ad236b6fabeb97935067bcd3719abaedcb344fb8831fc8b194837e5ab8ba5"
    }
  ]
}
curl --location 'https://starknet-mainnet.blastapi.io/<project_id>/builder/getTokenApprovals?fromBlock=515018&contractAddress=0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7&ownerAddress=0x0373aa6e162d47f9f0c6304d4580a0fed41552283dbf9936f3606581a5a84f69'

Last updated