twitter dm or email with any questions.
NOTE: Not ready for public use. Please reach out viaPonder
A framework for building blockchain-enabled web services
Features
- Support for ~80% of Graph Protocol subgraph features
- Event handlers run in Node.js (import packages, send HTTP requests, etc)
- Local development server with hot reloading
- Support for any EVM-based blockchain (just need an RPC URL)
Quickstart
I'm replacing a Graph Protocol subgraph
npx create-ponder-app
1. Run Include the --from-subgraph
option to bootstrap using an existing Graph Protocol subgraph.
npx create-ponder-app path/to/ponder-app --from-subgraph path/to/subgraph
2. Start the development server
cd path/to/ponder-app
npm run dev
The dev server process will print logs to help you handle any configuration issues or errors.
3. Add event sources
The ponder.config.js
file defines the event sources (EVM smart contracts) that Ponder will index. You can include contracts across multiple chains. You can also use any environment variables defined in .env.local
.
4. Write event handler functions
The handlers/
directory contains a file for each source defined in ponder.config.js
. The index.ts
file must export an object that maps event names to event handler functions.
Event handler files run in Node.js (not WebAssembly), so you can import NPM packages, send HTTP requests, and so on. While migrating your handlers from AssemblyScript to Typescript, you should consider updating your schema.graphql
to use String
instead of Bytes
, and Int
instead of BigInt
(in some cases).
Event handler functions receive two arguments - event
and context
. The event
object contains params
, block
, transaction
, and other useful log fields. The context
object contains a small ORM-style object for each entity defined in your schema.graphql
. Use these entity objects to insert, and update the entities that will be served via GraphQL, just like in your subgraph.
That's it! The development server should reload and reindex whenever you save changes in any project file. Keep an eye on the dev server process and handle any errors that appear.
I'm starting a new project
Coming soon!
Deploying to production
Ponder apps can be deployed on any cloud provider that offers a Node.js web service runtime.
Render
Coming soon!
Railway
Coming soon!
Docs
Project files
ponder.config.js
1. This file contains contract addresses, paths to ABIs, and RPC URLs for each of your sources. It is analogous to a subgraph's subgraph.yaml
file.
schema.graphql
2. This file works exactly like a subgraph's schema.graphql
. It supports the @entity
and @derivedFrom("field")
directives.
handlers/
3. This directory contains your event handler functions. Ponder uses these functions to process blockchain events. Event handlers can create and update Entities, which are served by the autogenerated GraphQL API.
abis/
4. This directory contains the ABIs for your contracts. You can download these files from Etherscan, or (more likely) generate them from a local smart contract development tool like Hardhat or Foundry.
generated/
5. This gitignored directory stores autogenerated Typescript types for your handler files to import. It also contains the final schema that is served by the GraphQL API.
.ponder/
6. This gitignored directory stores ponder's internal cache store and the compiled handler code. You shouldn't need to worry about it, but if you delete it, ponder will need to refetch any cached logs from the RPC.
Packages
@ponder/ponder
create-ponder-app
About
Goals
- Be the best tool for building blockchain app backends
- Work seamlessly alongside best-in-class frameworks like Foundry and Next.js
Non-goals
- Efficiently index massive amounts of data
- Serve analytics queries/workloads