Skip to content

Instantly share code, notes, and snippets.

@JPaulMora
Created February 7, 2019 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPaulMora/34a5e11b9c20885019656c926ed38e66 to your computer and use it in GitHub Desktop.
Save JPaulMora/34a5e11b9c20885019656c926ed38e66 to your computer and use it in GitHub Desktop.
Small node.js snippet to query current monero difficulty from local daemon.
const axios = require('axios');
let header = '';
for (let block = 1685551; block < 1685704; block++) {
axios.post('http://127.0.0.1:18081/json_rpc', '{"jsonrpc":"2.0","id":"0","method":"get_block_header_by_height","params":{"height":' + parseInt(block) + '}}').then(resp => {
header = resp.data.result.block_header
console.log(header.height + ', ' + header.timestamp + ', ' + header.difficulty)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment