Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active May 25, 2018 04:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WietseWind/d35c66fb22a5071357d2832fec6a561f to your computer and use it in GitHub Desktop.
Save WietseWind/d35c66fb22a5071357d2832fec6a561f to your computer and use it in GitHub Desktop.
Check XRPL burn
const websocket = require('websocket')
const RippleClient = require('rippled-ws-client')
const burnGtXrp = {
ledger: 5,
tx: 1
}
new RippleClient('wss://rippled.xrptipbot.com').then(connection => {
let atLedgerIndex = 38862032
let lastCoins = null
let fetchCount = 0
const fetchNextLedger = () => {
fetchCount++
connection.send({
command: 'ledger',
ledger_index: atLedgerIndex
}).then(response => {
let coins = parseInt(response.ledger.totalCoins) / 1000000
let diff = (lastCoins === null ? 0 : coins - lastCoins)
let diffGt = diff >= burnGtXrp.ledger ? '<FLAG>' : ''
console.log(`${response.ledger_index} ${response.ledger.close_time_human} ${coins.toFixed(6)} ${diff.toFixed(6)} ${diffGt}`)
if (diff >= 5) {
// Fetch the transactions responsible for the high burn rate
connection.send({
command: 'ledger',
ledger_index: response.ledger_index + 1,
transactions: true,
expand: true
}).then(ledgerData => {
ledgerData.ledger.transactions.forEach(tx => {
let txFee = parseInt(tx.Fee) / 1000000
if (txFee >= burnGtXrp.tx) {
console.log(`${tx.hash} burned: ${txFee.toFixed(6)} XRP (${tx.TransactionType})`)
// console.log(tx)
}
})
})
}
lastCoins = coins
atLedgerIndex = parseInt(response.ledger_index) - 1
fetchNextLedger()
})
}
fetchNextLedger()
}).catch(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment