The Block Explorer provides API functions to retrieve on-chain data from a Constellation Network indexer. The service uses PostgreSQL for data storage and retrieval and the Serverless framework for API deployment.
- Node.js (v18 or higher recommended)
- TypeScript
- Docker
- Serverless Framework
-
Clone the repository
git clone https://github.com/Constellation-Labs/block_explorer.git cd block_explorer -
Install dependencies
npm install
-
Start the PostgreSQL database
npm run db:start
-
Run the API locally
serverless offline
The project uses PostgreSQL for data storage. A Docker Compose configuration is provided for easy setup:
# Start the PostgreSQL container
npm run db:start
# To stop the container when finished
npm run db:stopThe database configuration is stored in .env and can be customized as needed.
Start the serverless offline host to test API endpoints locally:
serverless offlineThis will display a list of available endpoints that can be called locally.
Run tests with the following commands:
# Start the database if not already running
npm run db:start
# Run tests (this will reset and seed the database automatically)
npm run testThe test suite uses Jest and automatically resets the database schema before each test run.
API endpoints are defined in the routes/ directory with their handlers in src/handlers/.
Available endpoints include:
- DAG operations
- Metagraph information
- Token locks
- Actions
- Allow spends