You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to get all the tokens owned by a user (address). I see that he main contract imports IERC721Enumerable.sol but does not implement all of its functions (specifically tokenOfOwnerByIndex). Is there an easy way to implement this, based on the data the token maintains already?
One of the other things I thought of doing is emitting a Minted(address, quantity, startIndex, endIndex) event at the end of my mint function, and I assume I can later query for those events, but I'd much rather see if I can get these programmatically.
Thanks!
The text was updated successfully, but these errors were encountered:
If you are listening to events to build up some kind of database, note that each NFT minted emits a Transfer event (with the from address as the zero address). So, emitting a Mint event is not necessary.
@Vectorized Thanks! Perfect answer there, useful code and use cases.
The reason I added the Minted event is we're not actively listening to the contract, and it'd be far less events to collect than listening to Transfer.
Also, we'll further need to filter to filter Transfer events to those with a from address 0x0, since the event is also used to transferring between accounts, and burning.
I would like to get all the tokens owned by a user (address). I see that he main contract imports
IERC721Enumerable.sol
but does not implement all of its functions (specificallytokenOfOwnerByIndex
). Is there an easy way to implement this, based on the data the token maintains already?One of the other things I thought of doing is emitting a
Minted(address, quantity, startIndex, endIndex)
event at the end of mymint
function, and I assume I can later query for those events, but I'd much rather see if I can get these programmatically.Thanks!
The text was updated successfully, but these errors were encountered: