Created
September 14, 2017 13:38
-
-
Save wlib/766174692ef725dd2f5706bfb4edd5fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function getEthereumAssets(address) { | |
| const baseURL = "https://api.ethplorer.io/getAddressInfo/"; | |
| const fetched = await fetch(`${baseURL}${address}?apiKey=freekey`); | |
| const { tokens } = await fetched.json(); | |
| for (let i in tokens) { | |
| const token = tokens[i]; | |
| const name = token.tokenInfo.name; | |
| const balance = token.balance / (10 ** token.tokenInfo.decimals); | |
| const rate = token.tokenInfo.price.rate; | |
| console.log(`${name}: $${balance * rate}`); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment