This guide walks you through the steps to set up, compile, and run the application. The application is designed to create a Docker environment on your local machine and expose a port for the frontend application.
Before getting started, ensure you have the following installed on your local machine:
- Yarn: A package manager for JavaScript.
- Docker: A platform for developing, shipping, and running applications in containers.
Follow the steps below to install dependencies, generate code, compile, and start the application:
To install all necessary dependencies for the project, run the following command:
yarnThis command will read the package.json file and install all the required packages listed in the dependencies and devDependencies sections.
Next, generate models based on the schema (schema.graphql):
yarn genThis command will execute the model generation process.
To compile the project, run:
yarn compileIf you encounter any errors during the compilation process, comment out everything in the src/main.ts file and rerun the yarn compile command:
// src/main.ts
// Comment out all code if compilation fails
yarn compileThis step is crucial for ensuring that your project compiles correctly before moving on to Docker setup.
To set up the Docker environment, run:
yarn docker-startEnsure that Docker is installed and running on your system (Windows, macOS, or Linux). This command will start the Docker containers as specified in the Docker configuration (docker-compose.yaml).
After the Docker environment is up and running, generate the database migrations:
yarn gen-migThis command will create the migration files based on the database schema.
Once the migrations are generated, apply them to the database:
yarn apply-migThis command will execute the migration files and update database schema accordingly.
Generate the ABI (Application Binary Interface) files for the project by running:
yarn gen-abiThe ABI files are essential for interacting with smart contracts.
After the compilation and migration steps are complete, uncomment the code in the src/main.ts file:
// src/main.ts
// Uncomment the code that was previously commented outWith the src/main.ts file uncommented, recompile the project to ensure everything is working correctly:
yarn compileTo start the application, run:
yarn startThis command will launch subsquid's indexing service.
In a new terminal window, start the frontend application by running:
yarn serveThis command will start the graphql server and expose an endpoint accessible via a web browser or in your frontend application.