Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active April 25, 2021 04:32
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 WietseWind/4a3320a28686303522620f14d732c6be to your computer and use it in GitHub Desktop.
Save WietseWind/4a3320a28686303522620f14d732c6be to your computer and use it in GitHub Desktop.
Fetch all Trust Lines for an XRPL account
const Client = require('rippled-ws-client')
const main = async () => {
const client = await new Client('wss://xrplcluster.com')
let fetchMore = true
let marker = undefined
const lines = []
while (fetchMore) {
const data = await client.send({
command: 'account_lines',
account: 'rCSCManTZ8ME9EoLrSHHYKW8PPwWMgkwr',
marker
})
const lineCount = data?.lines?.length || 0
marker = data?.marker
fetchMore = lineCount > 0 && marker
console.log('Fetched # TrustLines:', lineCount, marker)
if (lineCount > 0) {
lines.push(...data.lines)
}
}
console.log('Got a total # TrustLines:', lines.length)
client.close()
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment