Quickstart
Last updated
Was this helpful?
Last updated
Was this helpful?
In this guide, we will set up a project that uses Checkpoint to expose data.
First, clone the Checkpoint starter template project that can be found at: .
To successfully, follow this guide and run the template project, you'll need the following dependencies set up on your computer:
Node.js (>=14.x.x)
Yarn
PostgreSQL (or Docker to quickly run an image).
First, install Node dependencies by running the following command in the project's directory:
Checkpoint projects (and by extension this template) require a PostgreSQL database connection to store indexed data. If you have a PostgreSQL server running, then create a copy of the .env.example
file and name .env
. Then update the DATABASE_URL
value in the .env
file to match the connection string to your database.
Next, start the server by running:
This will start the indexing process and also startup the GraphQL server for querying indexed information.
Now that the server is running, open up your browser and visit http://localhost:3000. This will show a GraphiQL interface to explore the exposed data.
Try executing the following query:
You should get a response similar to the one in this image:
The response to your queries depends on how much on-chain data Checkpoint has indexed. If the server has run long enough, you'll get more results. Checkpoint exposes a _metadata
query, which can be used to track the latest block it has indexed. Example of this is:
Here is a quick description of important files within the template project and what each does.
You are encouraged to try modifying the template project to understand how Checkpoint works and quickly get started using it to index your contracts data on Starknet.
This starter project defines a Post
entity in its src/schema.gql
schema file and is setup to write data based on that structure. Read more on how Entity schemas are used to generate GraphQL queries .
: Defines the Post
entity Checkpoint uses to generate API queries.
: Defines the object used to initialize Checkpoint and it contains the details of a Poster contracts deployed on Starknet mainnet and Starknet sepolia networks.
: Defines the responsible for writing Post
data whenever Checkpoint encounters a new_post
event.
: This is the entrypoint, that initializes Checkpoint, configures indexers for each network and exposes the GraphQL API.
: Defines blocks where we are sure the contracts events exists. This is used to seed checkpoint inside the index.ts file to speed up Checkpoints indexing.