Search code examples
javasolana

Solana rpc subscribe to account transactions


I am trying to listen for transactions for an account, I need to know when a transaction is received and get the hash of that transaction.

I am using Solana's json rpc api on https://api.testnet.solana.com

What I tried so far:

blockSubscribe: is unstable and disabled by default.

accountSubscribe: this will send the account balance but not the transaction.

logsSubscribe: tried passing account address as mentions but didn't work.


Solution

  • You need to use getConfirmedSignaturesForAddress2 then use getConfirmedTransaction to get the actual transaction.