We (Authereum) are looking for the best way to collect all token (and/or ETH) balances for a single address. This would look something like:
curl https://mainnet.infura.io \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"<custom_endpoint>_getTokenBalances","params": ["0xd0A7333587053A5BAe772BD37b9AAe724E367619"],"id":"42"}'
And would return:
{
"jsonrpc":"2.0",
"id":1,
"result": {
"address": "0xd0A7333587053A5BAe772BD37b9AAe724E367619"},
"tokenBalances": [{"contractAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F", "tokenBalance": "0x0d06e87e858e", "error": null}, {"contractAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "tokenBalance": "0x8457abc736", "error": null}, {"contractAddress": "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643", "tokenBalance": "0xab27ba", "error": null}]
}
The call would get all token balances for 0xd0A7333587053A5BAe772BD37b9AAe724E367619
and return only addresses with a balance. Ideally it would return all ERC20 tokens and let us (the caller) parse the data for “spam” tokens.
Optionally, this could return the ETH balance as well, but that may not fit into this scope.