0

What's the best way to filter in Solidity?

Specifically in a game such as CryptoKitties where there are thousands of different ERC721 tokens, how would you quickly filter to the 12 most expensive items, or the 12 youngest? Does adding a filter function to the blockchain itself make sense?

I know CryptoKitties does it with their own API server so I imagine they keep a copy of the database and filter that. Is that the recommended way to do things? Or could you ask the blockchain to do the filtering itself? What's the recommended solution when building a Dapp?

1 Answer 1

1

Personally, I'd keep that kind of computation off the chain- it's expensive (order of magnitudes more expensive- 400 times the cost of the same compute on say an AWS Lambda instance). I've written and used Smart Contracts as proof validators, rather than a place to build in extensive logic- otherwise the cost is too high, and it clogs the chain with things that don't really need immutability.

We aren't at the stage, or the price point (and probably will never be), that Ethereum replaces off-chain compute. We're at the stage that Ethereum provides consensus immutability to validate off-chain compute results.

Your Answer

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

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