How can we read program logs and instruction data for a specific program transactions for instance I want to keep track of all the transaction which happened for a particular NFT collection.
1 Answer
Your best bet is to fetch all past transactions involving the mint, and then subscribe to transactions from a program or account that can change.
To fetch the past transactions, the process is:
- get all signature with
getSignaturesForAddress
https://docs.solana.com/developing/clients/jsonrpc-api#getsignaturesforaddress - fetch each transaction by signature using
getTransaction
https://docs.solana.com/developing/clients/jsonrpc-api#gettransaction - read through each transaction
To subscribe to new transactions, you can use programSubscribe
to see all transactions from a particular program, e.g. the Metaplex Program https://docs.solana.com/developing/clients/jsonrpc-api#programsubscribe
Otherwise, you can also subscribe to changes to a metadata or collection using accountSubscribe
https://docs.solana.com/developing/clients/jsonrpc-api#accountsubscribe