Streaming Game Actions to Power Treasure Quests
Save time and resources in creating your next quest on the Treasure App.
For a partner creating quests on Treasure, we needed an automated way of answering “did the player complete this quest?” This involves checking off-chain actions, on-chain actions, or maybe a combination of both.
For off-chain actions, the Quests v1 system used a pull-based approach (”pulling” data from partners by calling partner APIs) that created extra development and operational burdens for both game partners and for Treasure.
The new Quests v2 approach takes a push-based streaming approach to simplify quest checking, reduces development efforts, and reduces operational burdens.
The Old Way
You set up an API endpoint for Treasure to query:
Cons
- Extra implementation effort: Requires you to write new backend logic to handle the HTTP requests.
- Extra design effort: You have to design and implement your own data collection, data cleaning, and data aggregation logic.
- Extra resources: The operational cost of deploying and maintaining the endpoint on an ongoing basis.
- Inflexible and narrowly scoped: All that effort just for 1 (or at best a few) distinct quests.
The New Way
You stream your game actions to the Treasure data platform (Darkmatter).
Pros
- Save implementation effort: Instrument your backend in 1 (or a few) key places to stream game data to us in the form of JSON messages.
- Save design effort: Checking the status of an off-chain / on-chain quest reduces to a simple SQL query on the Treasure side. You only have to decide what type of data to stream to us.
- Save resources: There’s no ongoing operational cost for the game partner. No extra endpoints or database for you to provision and monitor.
- Flexible, future-proof: The same data you’re streaming to us can be used for future quests or for more general analytics.
With the old approach, when you (the gamer partner) have to take care of data collection, normalization, and aggregation at the same time, that introduces a lot of burden and complexity on you.
The new Quests v2 approach is to decouple data collection from data use. Just push us the JSONs. We take care of the processing. Then you and Treasure can brainstorm some Quest SQL queries later.
Under the Hood: How does it work?
We’ve built our data ingestion platform using a Kafka-Flink streaming approach —- a duo that has been battle tested by game studios like Activision and Tencent, as well as large scale streaming applications in various industries that require fault tolerance, high throughput, and low latency data updates.
We ingest data from heterogenous data sources:
- from game partners like yourselves
- from the blockchain, where we use Goldsky’s Mirror to have raw blockchain events/transactions streamed into our Kafka topics.
These data sources feed into topics that we host on Redpanda Kafka clusters. These topics are a crucial staging area for the rest of our streaming infra.
Finally, Treasure Darkmatter distills the data into a more uniform format that allows for easier queries. A to Z in a series of composable reads / writes / transforms, where each stage is simple to understand and easy to debug.
Q&A
Q: How do you handle cheaters after the fact?
A: Consider this scenario —- you’ve streamed game actions to us, and later you discover that some players were cheating (or perhaps accidentally exploited a loophole) that affects the scores. There are a couple straightforward remedies in this case.
- (a) You can send us a list of player wallet addresses or game IDs to exclude. All we have to do on our side is to modify the Quests v2 SQL query to filter them out.
- (b) You can re-stream the previous data to us with the same identifiers, but with the message bodies modified to contain a new field that we can filter against (such as
{ ignore: true }
or{ cheater: true }
).
Q: What kind of game actions should we stream to Treasure for Quests v2?
A: Any of the following data can lay the foundation for a quest SQL query that we can formulate later.
- Game / match summaries
- In-game achievement events
- Lootbox reveals
- Whatever you can think of
You’re free to choose a level of granularity that makes sense.
Q: Is it possible to combine on-chain and off-chain quest criteria?
A: Yes. the Treasure Data Platform and ingest both off-chain and on-chain data and distill the results into easy-to-query datasets. You just need to give us an event signature like MyEvent(uint256 id, string message, bool[] boolMap)
, and our platform will automatically filter and decode those event and write them to our database.
See this section in our Quests documentation for details.
How do I get started?
Visit the Quests section to read about how you can start streaming data to us, and get in touch with us to set up your next Treasure Quest!