Furkan Çelik
Furkan Çelik

Reputation: 1

bsc get transaction list by address Web3 (realtime,socket)

How can I track transactions of a wallet in the bsc network instantly? (I am thinking of using web3 js.)

I don't want to do it with the api on BSCscan. As far as I know, it does not show it instantly.

Upvotes: 0

Views: 9097

Answers (1)

Petr Hejda
Petr Hejda

Reputation: 43581

Native BNB transactions:

You can subscribe to newBlockHeaders, which will emit an event each time a new block is mined. Using the block number or hash, you can get the list of transactions in the block. Your app can then filter only transactions that are relevant to your watched address.


Token transactions:

Subscribe to logs and filter the topics reflecting only the Transfer event to/from your watched address. In this case, you can perform the filter as a part of the subscription parameters, so that your app doesn't have to handle unnecessary data.


Edit: Provider https://bsc-dataseed1.binance.org/ that you used in your other answer gives error "Error: The current provider doesn't support subscriptions: HttpProvider". Which means you need to use a different provider that supports subscriptions or configure your own node.

Upvotes: 5

Related Questions