5

Given a PublicKey, how can I view all transactions associated with said PublicKey using web3js?

1
  • Just a note, if you are trying to get any and all history for a NFT using it's PublicKey -- some programs/sites don't include it correctly n the transaction and thus you won't be able to get every single event that ever took place.
    – statikdev
    Commented Jul 13, 2022 at 20:06

2 Answers 2

9

One solution would be to call getSignaturesForAddress (https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getSignaturesForAddress). This returns an array of 1000 signatures backwards in time from the provided/most recent confirmed block so if you have more than 1000 transactions in the history for your pubkey you'll need to call this in a loop. It takes an optional SignaturesForAddressOptions which contains before, you'll want to pass in the oldest signature from the last response.

Once you have all of your signatures, you can use getTransactions or getParsedTransactions (https://solana-labs.github.io/solana-web3.js/classes/Connection.html#getParsedTransactions) to get the transactions associated with your signatures.

2
  • is the getParsedTransactions meant to provide the from and to address as well? So far no luck Commented Aug 3, 2022 at 18:34
  • yes, getParsedTransactions should provide both to & from addresses.
    – Ake
    Commented Dec 28, 2023 at 2:08

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.