This is the API for the Qearn Dapp and transaction indexer of Qearn Smart Contract. It is built using Axum, PostgreSQL, Prisma Rust.
To begin with this project:
This project uses Prisma to generate the database client. To use prisma in rust, it is necessary to install the prisma-client-rust-cli
package. But new version of prisma-client-rust-cli does not support global installation(cargo install prisma-client-rust-cli
). So we need to install it in the project directory.
Refer this docs for more details.
This project already added alias for prisma
in .cargo/config.toml
. So you can use prisma
command to run prisma-cli.
$ cargo prisma generate
(if you installed prisma-client-rust-cli globally, you can use prisma-cli
command to run prisma-cli)
$ prisma-cli generate
To push db schema to database, you can use the following command:
$ cargo prisma db push
The most straightforward way to run Postgres is by using a container with a pre-built image. The command below will start latest version of Postgres using Docker:
$ docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
$ cp .env.sample .env
With everything else set up, all you need to do now is:
$ cargo run