Hello, guys!

Can someone give me a hand, please?

I have a list of Externally Owned Accounts and another of Contract Accounts. I am scanning every new block and i need to check if there are ERC721 transfers to one of my EOA accounts.

Does anyone know a way to do that? I am assuming that first i must determine if the transaction is related to an ERC20 or an ERC721 token transfer (checking event logs topics maybe? ERC20 2 indexed vs ERC721 3 indexed?)

Thanks :)

Jun 28, 2022, 2:41 PM
Listen for emitted Transfer events, filter out the eoa you want using 'to' from the event
But that's just opensea specific. I don't think there is any limitation on using any resolution, except that preview will suck
Jun 28, 2022, 3:17 PM
yes the previews will suck, that's the issue if intending to deliver a smooth experience
Jun 28, 2022, 3:18 PM
Thank you for your reply, Grim. How do you usually distinguish ERC20 and ERC721 when you scan blocks/filter transactions?
Jun 28, 2022, 4:17 PM
Using the topic length
Aka number of indexed params
Jun 28, 2022, 4:21 PM
Hmm, so I was right about checking ERC20 -> 2 indexed, ERC721 -> 3 indexed. I found this solution but was in doubt if it was not a bad practice.. Thank you.
Jun 28, 2022, 4:31 PM
Well, that's like the best existing solution for detecting erc20 vs erc721 transfers offchain
Or you'll have to make a supportsInterface call to all contracts and see if erc165 is implemented and is actually an implementer of ierc721
Jun 28, 2022, 4:33 PM
got it! thank you, ser!
Jun 28, 2022, 4:36 PM

© 2024 Draquery.com All rights reserved.