Last active
February 24, 2023 14:56
-
-
Save shortthefomo/ee4a920a24518dfb1f6c7be9ff1acd34 to your computer and use it in GitHub Desktop.
Fetch all transactions on an account.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { XrplClient } = require('xrpl-client') | |
const client = new XrplClient() | |
const account = 'rJeBz69krYh8sXb8uKsEE22ADzbi1Z4yF2' | |
const account_tx = { | |
'id': 2, | |
'command': 'account_tx', | |
'account': account, | |
'ledger_index_min': -1, | |
'ledger_index_max': -1, | |
'binary': false, | |
'limit': 200, | |
'forward': false | |
} | |
let account_txs = await client.send(account_tx) | |
if ('error' in account_txs) { | |
console.log('error', account_txs) | |
return | |
} | |
console.log('account_txs first batch length', account_txs.transactions.length) | |
let transactions = [...account_txs.transactions] | |
let count = 0 | |
while (account_txs['marker'] !== undefined) { | |
console.log('fetching next... ' + count) | |
account_tx.marker = account_txs['marker'] | |
account_txs = await client.send(account_tx) | |
if ('error' in account_txs) { | |
console.log('error', account_txs) | |
return | |
} | |
transactions = transactions.concat(account_txs.transactions) | |
count++ | |
} | |
console.log('marker', account_txs['marker']) | |
console.log('account_txs length', transactions.length) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment