0

How can I get a pro-apis key for test? I want to use these apis : https://pro-api.solscan.io/pro-api-docs/v1.0.

Actually, I want to fillter the accounts' transfers at websocket or https. when I use logsSubscribe at ws, there is only one public key can be set up, but we have a lot of accounts. and then I want to subscribe accountSubscribe topic at ws, but I don't know how many ws colections can be keep at sametime.

If someone had the experience as me, please answer me, it's very urgent! thanks so so much!

1 Answer 1

0

You might use use map and an array of public key strings to listen to many tens of thousands at one time

const publicKeyStrings = [...]

const publicKeys = publicKeyStrings.map((pubKeyStr) => new PublicKey(pubKeyStr));

publicKeys.map(async (publicKey) => {
  connection.onAccountChange(publicKey, async (accountInfo) => {
    const balance = accountInfo.lamports;
    console.log(balance, publicKey)
  });
});
2
  • Thanks for your kind answer! Your example could listened the change of balance, but couldn't get the detail transaction that from another acount or sent by itself. I hope that I can know the account's transactions. like a tx scanner.
    – Ricky
    Dec 19, 2023 at 11:59
  • On the callback you might try to have it call getSignaturesForAddress, {limit: 1}, then getParsedTransaction on that and you'll have the latest transactions details
    – spaghetti
    Dec 24, 2023 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.