How Does MEW Know What Tokens I Have?

MelbourneDeveloperMelbourneDeveloper Member Posts: 4
edited June 20 in web3-js
This is really a question about JSON RPC. I know that I can get eth_call to get the balance of a token at an address, but I've been looking everywhere to be able to figure out how to get the tokens that are at a given address.

This here will get the balance of TRX at an address:
{"id":1,"jsonrpc":"2.0","method":"eth_call","params":[{"to":"0xf230b790e05390fc8295f4d3f60332c93bed42e2","data":"[ADDRESS ABI]"},"latest"]}

But, the above won't tell me which tokens are at a given address. However, MyEtherWallet somehow knows...

When I plugged my Trezor in, it saw that there was TRX associated with my account. I did a trace with fiddler, and the only HTTP transfer I saw was the above JSON RPC call. How is MEW figuring out which tokens are at the address?

This is an API that allows this to be done, but I'm guessing that is from an indexed database and not through the JSON RPC:
https://api.ethplorer.io/getAddressInfo/0xff71cb760666ab06aa73f34995b42dd4b85ea07b?apiKey=freekey

Comments

  • dra9onsdra9ons Member Posts: 7
    The address of the token contract is required to know the balance of the token. You can retrieve the balance of the desired address by calling the balanceOf method of the token contract.
Sign In or Register to comment.