This project is a Rust-based API for creating and managing smart contracts written in Ink!. It utilizes the Rocket framework and several other Rust crates.
- Clone this repository
- Install Rust by following the instructions on rustup.rs
- Run
cargo build --release
- Install nightly version
rustup toolchain install nightly
, set it as defaultrustup default nightly
, and update withrustup update
- Install cargo contract following the instructions
- Install MongoDB by following the instructions on mongodb.com
- Rename the .env.example file in the root of the project to .env and fill in the following environment variables:
MONGOURI=<The URI of your MongoDB instance>
- Run the API executing:
./target/release/compiler-be
created in step 3
The project consists of four main modules:
api
: contains the API endpoints for creating and managing contractsmodels
: contains the data models used by the APIrepository
: contains the repository for interacting with the databaseutils
: contains various utility functions used by the API
The API has a single endpoint:
POST /contract
: accepts a JSON payload representing a contract and returns the compiled contract if already exists or it compiles it, stores in the database and returns it.
POST /contract
: The request body must be a JSON object with the following fields:
address
: The wallet address of the request sendercode
: The smart contract code written in Ink! in plain textfeatures
: The smart contract standard and some open brush modifiers that would be needed to be imported by the Cargo.toml file
The response will be a JSON object with the following fields:
code_id
: The unique identifier of the smart contractmetadata
: The smart contract generated metadatawasm
: The web assembly code obtained from compiling the smart contract