I am trying to track a wallet address and whenever it does something to emit an event. This is for BSC btw

Here is the code

 var subscription = web3.eth.subscribe('logs', {
        address: '0x6F8Baf6076604A7b5e56d2C082bc9c205525Db84',
    }, function(error, result){
        if (!error)
    }).on("data", function(e){
        console.log("p" + e)
    }).on("error", function(e){
        console.log("p" + e)

When I send a test transfer, nothing emits.

But if I subscribe to ALL transactions, then compare each to the desired address, it works.

I don't want to subscribe to all transaction and am wondering if there is a way to listen to a specific wallet transactions only.

1 Answer 1


I also looked for a solution for a single address, but unfortunately there is no solution. I'm adding this here for those who happen to pass by.

async function listenTransaction(receiver, callback) {
    // Web3 provider needs to be websockets
    let balance = await web3.eth.getBalance(receiver);
    let subscription = web3.eth.subscribe('newBlockHeaders');

    subscription.on("data", async (blockHeader) => {
        let newbalance = await web3.eth.getBalance(receiver);
        if (balance < newbalance) {
            balance = await web3.eth.getBalance(receiver);
            let currentBlock = await web3.eth.getBlock(blockHeader.hash, true);
            currentBlock.transactions.forEach(transaction => {
                if (transaction.to && transaction.to.toLowerCase() == receiver.toLowerCase()) {
                    callback(transaction.hash, subscription);

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.