Skip to content

Instantly share code, notes, and snippets.

@WietseWind
WietseWind / index.mjs
Last active July 4, 2022 23:35
Fun with Generator Functions. First backfill XRPL Ledgers, then keep up with current Ledgers closing, fall back to backfilling if needed to sync gaps.
import { XrplClient } from 'xrpl-client'
const config = { backfillLedgers: 20, lastLedger: null }
const client = new XrplClient(['wss://xrplcluster.com'])
await client.ready()
config.lastLedger = client.getState().ledger.last - config.backfillLedgers
function getLedgerTransactions(ledger_index) {
return client.send({ command: 'ledger', transactions: true, expand: true, ledger_index })
@shortthefomo
shortthefomo / ntfDeriveSale.js
Last active November 5, 2022 01:35
XTPL NFT deriveSale
//pass tx as returned from ledger
ntfDeriveSale(tx) {
let hash = tx.hash || tx.transaction.hash
let trade = {}
let taker = tx.Account
for(let affected of (tx.meta || tx.metaData).AffectedNodes){
let node = affected.DeletedNode
if(!node || node.LedgerEntryType !== 'NFTokenOffer')
continue