POST
/getBalanceForStarknetToken
Retrieves the balance of a specific ERC20-compatible token for a given address on Starknet. This function
queries the token contract's balance_of function using the standardized ERC20 interface, returning both the
raw balance amount and the token's decimal configuration for proper display formatting.
The function interacts with Starknet ERC20 token contracts that follow the Cairo implementation of the ERC20
standard. It automatically handles the contract call mechanics and provides decimal information to help with
proper token amount representation in user interfaces.
Internally, this function calls the token contract's balance_of entry point (selector 0x035a...af33) and
decimals entry point (selector 0x004c...8a9) to gather complete balance information. The raw API responses
include the standard FunctionData and Meta structure, but this method processes those responses and returns
a simplified format containing only the essential balance and decimal information.
This is a read-only operation that does not modify blockchain state and does not require gas fees to execute.
The function combines two separate contract calls to provide comprehensive balance information in a single response.
Read more about Starknet ERC20 tokens at https://docs.starknet.io/documentation/developing/smart-contracts/erc20/
Return: Dictionary containing the token balance and decimal configuration.
Input Example: getBalanceForStarknetToken("0x0471...938D", "0x035a...af33")
Response Example:
{
"Balance": "149971532366926211962",
"Decimals": 18
}
token_contract_addressstring<p>The Starknet contract address of the ERC20-compatible token to query. Must be a valid Starknet address format starting with "0x".</p>
addressstringThe wallet address to check the token balance for. Must be a valid Starknet address format.
acceptstringGenerated from available response content types
200success
curl --request POST \
--url '/getBalanceForStarknetToken?token_contract_address=string&address=string' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"FunctionData": {
"AccountId": 1
},
"Meta": {
"FunctionName": "getEthValidatorsSummary",
"RandomData": "288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229",
"Destination": "b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea",
"Time": "2021-02-07T18:37:46.948Z",
"Source": "048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99",
"AccessToken": "51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087"
}
}'