Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

307
Visualizações
Web3js event listen / subscribe to transactions to or from a wallet address

So I am connecting to Binance Smart Chain RPC websocket from Moralis.io. And trying to listen to wallet amount changes of a certain wallet address.

What I want to do is, I want to trigger a event whenever there is a transfer from or to this wallet address. I understand how to do it with BEP20 tokens but I require a solution to monitor the wallet address for BNB transfers.

The code that I put together:

const web3 = new Web3(new Web3.providers.WebsocketProvider('URI'))

let options = {
address: '0xe....'
}

const subscribe = web3.eth.subscribe('logs', options, (err, res) => {})

subscribe.on('data', (txLog) => console.log(txLog))

This doesn't work when I send a certain amount of BNB to this account.

I went through the documentation of web3js but couldn't figure out.

I found a longer way around for this problem where someone suggests to listen to all pending transactions and try to get the transaction data of each of these transactions and evaluate if any of these are from or to the wallet address. But I think it is an extremely ineffective and inefficient way to do it as it requires someone to run their own node to do it in a meaningful way.

Please guide me through this. Thanks

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

listen to all pending transactions and try to get the transaction data of each of these transactions

I agree that this is an ineffective way. But with the current state of the JSON-RPC API, it's still the most effective way available. Apart from using a 3rd party service that does all this work in the background and provides the data over their custom API.

Note: The link goes to Ethereum documentation, but Binance Smart Chain implements the same JSON-RPC API.

There's simply no method to subscribe to or poll incoming native transactions to a specified address.

And since web3, ethers.js, and many other libraries are wrappers of this API, they can only support methods that the API supports.

about 4 years ago · Juan Pablo Isaza Relatório

0

There is an answer here to your similar question, which in this case the is on Polygon Blockchain, but they still do operate in same way with BNB.

https://stackoverflow.com/a/72491615/13180064

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda