Skip to content

Instantly share code, notes, and snippets.

@wlib
Created September 14, 2017 13:38
Show Gist options
  • Select an option

  • Save wlib/766174692ef725dd2f5706bfb4edd5fc to your computer and use it in GitHub Desktop.

Select an option

Save wlib/766174692ef725dd2f5706bfb4edd5fc 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