Skip to main content

getTokenApprovals

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 *stringThe token contract address
fromBlockstringThe block number from which the approvals will be returned
toBlockstringThe block number up to which the approvals will be returned
ownerAddressstringThe address of the approver
spenderAddressstringThe address of the spender
pageSizeintegerNumber of records to be retrieved on one page
pageKeystringKey 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
contractAddressstringThe token contract address
contractDecimalsstringToken decimals specified in the contract
contractNamestringThe name of the token
contractSymbolsstringThe symbol of the token
countintegerThe number of token approvals
nextPageKeystringKey to get the next page of results, if more results are available
tokenApprovalsarrayThe array containing all token approvals
ownerAddressstringThe wallet address of the approver
spenderAddressstringThe address of the spender
valuestringThe amount of tokens approved
blockHashstringThe hash of the block in which the transfer transaction was executed
blockNumberintegerThe height of the block in which the transfer transaction was executed
blockTimestampstringThe timestamp of the block in which the transfer transaction was executed
transactionHashstringThe hash of the token transfer transaction
transactionIndexintegerThe number of the token transfer transaction
logIndexintegerThe 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.

info

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!

curl --location 'https://starknet-mainnet.blastapi.io/<project_id>/builder/getTokenApprovals?fromBlock=515018&contractAddress=0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7&ownerAddress=0x0373aa6e162d47f9f0c6304d4580a0fed41552283dbf9936f3606581a5a84f69'