Closed dharmveersinh closed 4 years ago
Hello @dharmveersinh , can you try passing addresses as an array ?
var filter = contrat.events.Transfer({filter: {to: ['0x4601A10F14C480d22830070aCF6c2c5455DAC27D', '0x4601A10F14C480d22830070aCF6c2c5455DAC27E']}, room: 'latest'});
filter.watch(async function(data, removed){
console.log('QRXD Recived');
var a = await web3.eth.getTransaction(data.transactionHash);
console.log(a);
});
Hello @itzmeanjan, Appreciate your help but it's not working. Giving me:
.../Test/EthereumTest/node_modules/@maticnetwork/dagger/lib/contract.js:66
return (t || '+').toLowerCase();
^
TypeError: (t || "+").toLowerCase is not a function
Here is the updated code:
var filter = contrat.events.Transfer({filter: {to: ['0x4601A10F14C480d22830070aCF6c2c5455DAC27D', '0x8b88Ce99Bca33708C9A3414f3DbC34b181A3d6BB']}, room: 'latest'});
filter.watch(async function(data, removed){
console.log('QRXD Recived');
var a = await web3.eth.getTransaction(data.transactionHash);
console.log(a);
});
Looks like to
array is being passed as it is, not iterated over. But you can give it a try, where you get notified for keccak256(Transfer(...))
topic, where you get to set to
/ from
addresses or leave it by putting *
/ #
.
Let me know how does it behave.
What I really wanted to do is, just filtering out the transfer events emitted with my multiple addresses on someone's contract. EX: There is a USDT's contract and I have multiple addresses, so whenever any transaction is emitted with those addresses I get notified and I can do further process.
Then you can create multiple subscriptions.
But I have more than 1000 addresses. Will it be a memory/CPU issue?
Yes it'll be. And I guess even if it was allowed to set multiple addresses as an array, it won't let you set that many under a single subscription. Rather you can give it a try and then filter out your address related events. And create same filter for each of ERC20 which you want to track.
What I am understanding in this code is:
dagger.on('latest:log/0xa74476443119a942de498590fe1f2454d7d4ac0d/filter/0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef/0x7da82c7ab4771ff031b66538d2fb9b0b047f6cf9/#', ...)
Contract address:0xa74476443119a942de498590fe1f2454d7d4ac0d
No idea what this is:0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
Account address: 0x7da82c7ab4771ff031b66538d2fb9b0b047f6cf9
So after the last address and before '#' I can add multiple account addresses which I want to filter, right?
Well, I tried doing:
dagger.on('latest:log/0x9dd6a7dc18f20a3dcb4d422a7387747072524886/filter/0x4601A10F14C480d22830070aCF6c2c5455DAC27D/0x8b88Ce99Bca33708C9A3414f3DbC34b181A3d6BB/#', result => {
console.log("New Log : ", result)
})
No Output on any address of these two addresses I tried.
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
This is web3.utils.keccak256('Transfer(address,address,uint256)')
So after the last address and before '#' I can add multiple account addresses which I want to filter, right?
No you can't, you're going to receive all Transfer
events where from
is some address but to
can be anything
0x4601A10F14C480d22830070aCF6c2c5455DAC27D
I'm not sure which event are you trying to listen
Thank you for the Information. I guess I need to add multiple subscriptions over my different addresses.
Hello, Currently, I am using the following code to filter the transaction:
But how can I filter multiple addresses? Thanks in advance.