INTRODUCTION
IntroductionGameplayGlossaryGUIDES
Build ShipMove ShipGather FuelMine AsteriaBackend APICHALLENGES
Preview ChallengeProject Asteria provides a GraphQL
API to query the state of the game. The primary query used is objectsInRadius
, which retrieves objects within a specified radius around a given point.
Below is an example of a query to get objects around the center point (0,0) with a radius of 10:
A preview testnet GraphQL
endpoint is available at https://dmtr_scrolls_v0_preview_1t9nhgnmxtpzrzm2gwv0723cu.scrolls-m0.demeter.run/graphql.
The backend uses a SQL query with a Manhattan distance calculation to find objects within the specified radius. The query ensures that the objects are within the bounds defined by the radius and the center point.
The database consists of UTXOs in the smart contract validators. These UTXOs are projected into a materialized view using Mumak, a PostgreSQL extension that allows developers to project or filter CBOR data within PostgreSQL. The generated materialized view is queried by the backend API as if it were a regular table. This enables efficient distance queries over CBOR data directly within PostgreSQL.