Get txs with data of an address

Hello,

how can I get all the ethereum transactions that contains ‘mydata’ of a specific address? if possible using web3js and with only one api call

Thanks

Hey @damland, you’ll want to use the web3.eth.subscribe function described here: https://web3js.readthedocs.io/en/v1.2.6/web3-eth-subscribe.html
Alternatively, there’s a great library called Subspace built on top of web3.js that I just wrote a post about here: https://blog.infura.io/frontend-dapp-development-2/.

Are you looking for every transaction containing ‘mydata’ from every block ever, or each newly mined block?

Using web3.eth.subscribe will it be considered a request call to infura for every tx find? If for example a new pending tx is found and I have 100 users in that page will it make 100 requests at the same time?

@Sean_Infura every transaction containing ‘mydata’ from every block ever, Thanks

Each of those 100 users will be in 1 request. So conceivably each block could be 1 request. I think https://github.com/ethers-io/ethers.js/issues/487 has a great overview of how to subscribe to events for “mydata”

I have this very same problem: https://github.com/ethereum/web3.js/issues/1752 (no error and no result)
eth.subscribe using infura does it work only for contracts?
Thanks

Hey, based on your other question on the forum it looks like you got this solved.

its working but only for contracts