'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 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maximilian Schneider