goodbye2012hix

Check block bsc

Nov 30th, 2021 (edited)
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var startBlock = 13078996;
  2. function check() {
  3.     var http = new XMLHttpRequest();
  4.     var url = 'https://bsc-dataseed.binance.org/';
  5.     var params = '{"jsonrpc":"2.0","id":256,"method":"eth_blockNumber","params":[]}y';
  6.     http.open('POST', url, true);
  7.  
  8.     //Send the proper header information along with the request
  9.     http.setRequestHeader('Content-type', 'application/json');
  10.  
  11.     http.onreadystatechange = function() {//Call a function when the state changes.
  12.         if(http.readyState == 4 && http.status == 200) {
  13.             var result = JSON.parse(http.responseText);
  14.             console.log(startBlock - parseInt(result.result, 16));
  15.         }
  16.     }
  17.     http.send(params);
  18.  
  19. }
  20. setInterval(function(){ check(); }, 300);
RAW Paste Data