sui icon indicating copy to clipboard operation
sui copied to clipboard

View relevant NFT from same collection

Open bwann52 opened this issue 2 years ago • 4 comments

On smart contracts page, browse NFT created by the smart contracts. What this means for the backend is to expose an API like getObjectsByType(package, Option<module_name>, Option<Struct_name>), e.g., 0x2::Coin::Coin<0x2::SUI::SUI>

Context: https://mysten-labs.slack.com/archives/C02DRAL32GN/p1652295738138789

In Gateway/Fullnode API, we should support indexing objects by Owner Address and type in general. The use cases are:

  • For the Explorer use case, return all objects whose package_id == '0x3'
  • For Gaming use case, return all objects whose owner == '0x32342' and package_id == '0x3'. For this we need a getObjectsByOwnerAndType method. We could also consider introducing something more general like getObjectsWithFilter()

bwann52 avatar Mar 31 '22 23:03 bwann52

This has a preresquisite to actually have collections.

gdanezis avatar Apr 19 '22 17:04 gdanezis

Collections are not strictly necessary.

This could be done today @bwann52 or soon in two steps:

  1. Query events (NewObject creations) by package, module name, function
  2. Query objects specified in those events

velvia avatar Jun 14 '22 23:06 velvia

@velvia Does that solution enable the following?

Developer John wants to checkout latest NFT drops, so he click on a SUI NFT leaderboard and click on ShadowNinjas,taking him to either 1)The ShadowNinjas module page where all ShadowNinjas NFTs are listed, or 2)Some view where all the ShadowNinjas NFTs are listed

Similarly, marketplace would also like to be able to display, in gallery view, all NFTS from some collection.

bwann52 avatar Jun 15 '22 21:06 bwann52

@bwann52 if you assume that all the NFTs are created by a specific module/package, then yes:

  1. Querying events by that specific package/module tells you all the objects that are created by that module;
  2. Those objects can then be inspected and filtered to get the NFTs that have been created.

The only thing is that the events would be time oriented but you can specify a large time window.

velvia avatar Jun 16 '22 18:06 velvia