Guest User

Untitled

a guest
Mar 22nd, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  2.  
  3. <div class="row" id="stats">
  4. <div class="col-4 col-12-large">
  5. <h4><strong>Ether contributed</strong></h4>
  6. <span id="eth_balance" style="font-size: 2.5em;">&mdash;</span>
  7. <!--<p id="total-ether-message" style="font-size:11px;"></p>-->
  8. </div>
  9. <div class="col-4 col-12-large">
  10. <h4><strong>Contributions in USD</strong></h4>
  11. <span id="token_usd" style="font-size: 2.5em;">&mdash;</span>
  12. <!--<p id="total-usd-message" style="font-size:11px;"></p>-->
  13. </div>
  14. <div class="col-4 col-12-large">
  15. <h4><strong>Tokens issued</strong></h4>
  16. <span id="token_amount" style="font-size: 2.5em;">&mdash;</span>
  17. <!-- <p id="total-tokens-message" style="font-size:11px;"></p> -->
  18. </div>
  19. </div>
  20.  
  21. var token = '0xa74476443119A942dE498590Fe1f2454d7D4aC0d';
  22. var address = '0xda0aed568d9a2dbdcbafc1576fedc633d28eee9a';
  23.  
  24. $.get("https://api.tokenbalance.com/token/" + token + "/" + address +'', function(data) {
  25. $("#eth_balance").html(Math.round(data.eth_balance).toFixed(2) + " ETH");
  26. $("#token_amount").html(Math.round(data.balance).toFixed(2) + " " + data.symbol);
  27. });
  28.  
  29. $.get("https://api.etherscan.io/api?module=stats&action=ethprice", function(data) {
  30. $("#token_usd").html("$ " + Math.round(data.result.ethusd).toFixed(2));
  31. // Ideally I'd like to get [ data.result.ethusd x data.eth_balance ] to replace #token_usd, all wrapped in one function
  32. alert(data.result.ethusd)
  33. });
Add Comment
Please, Sign In to add comment