Getting Token Balances Just Got A Lot Easier
The Enhanced API method alchemy_getTokenBalances has long been the best way for developers to get access to the balances of a list of tokens in a given wallet.
However, until now, this method required users to provide us with an explicit list of all token addresses they were interested in querying. Some developers found this laborious, so we’ve introduced a new option: developers can now simply call ‘alchemy_getTokenBalances’ with the value ‘DEFAULT_TOKENS’ to see the balances of the top 100 tokens by 24 hour volume.
So this:
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"alchemy_getTokenBalances","params": ["0xYourWalletAddress", [0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xf5d669627376ebd411e34b98f19c868c8aba5ada, 0x3506424f91fd33084466f402d5d97f05f8e3b4af, 0x0f5d2fb29fb7d3cfee444a200298f468908cc942, 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984, ...etc 95 more times]
],"id":"42"}'
Just became this:
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"alchemy_getTokenBalances","params": ["0xYourWalletAddress", "DEFAULT_TOKENS"],"id":"42"}'
Try it out in the composer!
And the best part, you can get started right away by making an Alchemy account free.
Related articles
Polygon Mumbai Support Ending April 13th - Migrate to Amoy
Polygon will deprecate the Mumbai testnet on April 13th, 2024. We encourage developers to migrate to Polygon Amoy immediately.
Polygon zkEVM Testnet Support Ends April 6 - Migrate to Sepolia
Polygon zkEVM Cardona is now supported on Alchemy! Support for the Polygon zkEVM Goerli testnet ends April 6th. Migrate today.
Starknet Goerli Support Ending April 11th - Migrate to Sepolia
Starknet Sepolia is now supported on Alchemy, and we will stop supporting Starknet Goerli on April 11th. We encourage developers to migrate to Sepolia.