Skip to content

Instantly share code, notes, and snippets.

@mertimus
Created August 16, 2022 17:51
Show Gist options
  • Save mertimus/3cf3026c28f78acb70803415bbec048d to your computer and use it in GitHub Desktop.
Save mertimus/3cf3026c28f78acb70803415bbec048d to your computer and use it in GitHub Desktop.
const axios = require('axios');
const apiURL = 'https://api.helius.xyz/v0/addresses/';
const address = '8cRrU1NzNpjL3k2BwjW3VixAcX6VFc29KHr4KZg8cs2Y';
const resource = '/transactions';
const options = '?api-key=d63a869e-bb73-4792-ae33-a06f4c72f226&before=';
let lastTxn = '';
const allTxns = [];
const getAllTxns = async () => {
while(true) {
console.log("fetching transactions...")
const { data } = await axios.get(apiURL + address + resource + options + lastTxn)
if(!data.length) {
console.log("got all transactions")
break
}
lastTxn = data[data.length - 1].signature
allTxns.push(...data);
}
console.log("Total transactions: ", allTxns.length)
}
getAllTxns()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment