Check the Balance of an ERC-20 Token in a Wallet
To check the balance of any ERC-20 token in a wallet, send a GET request to the /wallet/wallets/erc20/balance
endpoint, calling the :retrieve
method. The wallet name and token contract address are also passed as query parameters.
Check the balance of an ERC-20 token in a wallet
GET
https://api.playfix.io/wallet/erc20/balance:retrieve
Query Parameters
wallet*
String
Name of the wallet that stores the ERC-20 token. This should be the value of name
from the response of a previously created wallet. It begins with "wallets/
", followed by a ULID.
contractAddress*
String
Contract address of the ERC-20 token.
Headers
Authorization*
String
Bearer <your_access_token>
{
"balance": "1000000000000000000",
"formattedBalance": ""
}
Example cURL API Call
curl --request GET \
--url 'https://api.playfix.io/wallet/erc20/balance:retrieve?wallet=<wallet_name>&contractAddress=<token_contract_address>' \
--header 'Authorization: Bearer <your_access_token>'
Example Python API Call
import requests
wallet = "<wallet_name>"
contractAddress = "<token_contract_address>"
r = requests.get(
"https://api.playfix.io/erc20/balance:retrieve?" +
"wallet=" + wallet + "&contractAddress=" + contractAddress,
headers={
"authorization": "Bearer <your_access_token>"
}
)
print(r.text)
Request Query Parameters
wallet
- Name of the wallet that stores the ERC-20 token. This should be the value ofname
from the response of a previously created wallet.contractAddress
- Contract address of the ERC-20 token. You can get this by reading the details of the token.
Response
{
"balance": "1000000000000000000",
"formattedBalance": ""
}
Response Fields
balance
- The quantity of the ERC-20 token available in the wallet.formattedBalance
- How the balance is displayed on the user interface.
Last updated