This project is a SubQuery indexer for the DSponsor protocol, designed to index events from Soroban (Stellar) smart contracts. It's part of a larger project involving the migration of an Ethereum dApp to Stellar.
The project is organized as follows:
schema.graphql: Defines the indexed data schemaproject.yaml: Indexer configuration and event handlers setupsrc/mappings/: Contains TypeScript mapping functions that process events
The indexer primarily tracks events from the dsponsor-admin contract, including:
- Creation of ad spaces
- Ad submissions
- Ad validations/reviews
- Install dependencies:
npm install- Generate types:
npm run codegen- Build the project:
npm run build- Start the indexer:
npm run devThe project is configured to index events from a specific block on the Stellar network. The main event filters are defined in project.yaml:
handler: "handleInitialization"
kind: StellarHandlerKind.Event
filter:
topics: ["PROPOSAL", "REVIEW"]
contractId: "CAY2NBEY3M7DTFKRYBVNRN66XXZ6TSQ4IUJD3KAMUHVMQRQDG5IU7GCC"Once the indexer is running, you can query the data through the GraphQL interface available at http://localhost:3000.
Example query for the initialization event:
query {
initializations {
nodes {
id
nftFactory
nativeXlm
bps
admin
}
}
}To modify the indexer:
- Update the schema in
schema.graphql - Generate types with
npm run codegen - Modify handlers in
src/mappings/ - Rebuild and restart the indexer
- Real-time indexing of DSponsor contract events
- Efficient data querying through GraphQL
- Support for ad space management and validation workflow
- Integration with Soroban's event system
The indexer processes several types of events:
- Ad space creation and initialization
- Ad proposal submissions
- Review/validation events
- Protocol configuration updates
Each event is parsed and stored according to the schema defined in schema.graphql, making the data easily queryable through the GraphQL API.
If you encounter any issues:
- Check the SubQuery Documentation
- Join SubQuery Discord
- Open an issue in the repository
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a Pull Request with a clear description of your changes
This project is licensed under the MIT License - see the LICENSE file for details