0

so I was just wondering on how CryptoKitties work. Like in order to query the price of each Kitty, do they querry like every single Kitty's price and then sort it out. Or is there a function or a better way to do this method.

In other words, if I have 1,000 elements do I have to "read" all 1,000 elements to query the results and thus makes a ranking of most expensive kitties? Or is there a function used to do this in the Smart Contract.

1 Answer 1

0

Cryptokitties does not read all elements from smart contract. It would not be feasible, especially think that it is open to DoS attack in that way, because possibly Infura can not handle those much requests. You can think an architecture like as follows:

  • When a new kitty is created, fire a CreatedEvent
  • Listen events emitted on your contract, and store events in SQL/NOSQL or somewhere else.
  • Create a backend service that queries over kitties etc.

PS: There is no SPOF for loose of funds/cats. An api link from cryptokitties : https://api.cryptokitties.co/cattributes

1
  • Ohh that makes so much sense. Thanks so much for that Mehmet Dogan :) Aug 10, 2018 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.