Skip to content

Instantly share code, notes, and snippets.

@wlib
Created September 14, 2017 13:38
Show Gist options
  • Save wlib/ccf5d9edd5f85eb159f89550901742bc to your computer and use it in GitHub Desktop.
Save wlib/ccf5d9edd5f85eb159f89550901742bc to your computer and use it in GitHub Desktop.
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