Skip to content

Playground for implementing Substrate code before it can be converted to Parachain Runtime Builder configs

Notifications You must be signed in to change notification settings

MVPWorkshop/ssk-substrate-playground

Repository files navigation

Substrate Runtime Builder

This project is a web-based application built using Rust and Actix Web. It allows users to generate Substrate projects with selected pallets and download them as zip files. The project uses the substrate-runtime-builder crate to dynamically generate Substrate-based blockchain projects.

Features

  • Create a new Substrate project with selected pallets.
  • Download the generated project as a zip file.
  • Handle multiple requests concurrently using async execution with Actix Web.

Prerequisites

Before running this project, ensure that you have the following installed on your system:

Getting Started

1. Clone the Repository

git clone https://github.com/MVPWorkshop/ssk-substrate-playground
cd ssk-substrate-playground

2. Build the project

cargo build

This will download all necessary dependencies, including actix-web, serde, and substrate-runtime-builder.

3. Install cargo-dotenv to run with enviroment files

cargo install cargo-dotenv

4. Run the Application

To start the server, run:

cargo dotenv -e .env.local run

5. Run the docker-compose

docker-compose up -d

The server will start at http://127.0.0.1:8080. You should see the following message in the console:

Starting server at http://127.0.0.1:8080

The server is now running, and you can make API requests to generate and download Substrate projects.

API Endpoints

1. Generate a New Substrate Project

Endpoint: /generate-project

Method: POST

Request Body (JSON):

{
    "name": "your_project_name",
    "pallets": [
         "Assets",
        "Bounties",
        "Treasury",
        "Vesting",
        "Society",
        "Utility",
        "Identity",
        "Multisig",
        "Proxy",
        "Nfts",
        "Uniques",
        "Membership",
        "ChildBounties"
    ]
}

The name field specifies the name of the project, and the pallets field is an array of pallet names you want to include in the project.

Example Request:

bash

curl -X POST http://127.0.0.1:8080/generate-project \
-H "Content-Type: application/json" \
-d '{"name": "my_project5", 
"pallets": [
            "Utility", 
            "Identity", 
            "Multisig", 
            "Proxy", 
            "Assets", 
            "Treasury", 
            "Vesting", 
            "Membership", 
            "Society"
            ], 
"push_to_git": false, 
"github_username": "username", 
"github_token": "Github_token", 
"github_email": "email"
}'

Response:

If the project is successfully created, you will receive the following message:

'my_project' project generated successfully.

2. Download the Generated Project

Endpoint: /download-project/{name}

Method: GET

After generating the project, you can download it as a zip file using this endpoint. Replace {name} with the name of the project you generated.

Example Request:

curl -o my_project.zip http://127.0.0.1:8080/download-project/my_project

This will download my_project.zip to your current directory.

Response:

If the project is found, you will receive the zip file for the project. If the project does not exist, you'll get a 404 Not Found response.

3. Fetch the template data including all the pallet information.

Endpoint: /templates

Method: GET

Fetch the all template data.

Example Request:

curl -X GET "http://127.0.0.1:8080/templates"

Fetch the solochain template data.

Example Request:

curl -X GET "http://127.0.0.1:8080/templates?template_type=solochain"

Fetch the solochain template data.

Example Request:

curl -X GET "http://127.0.0.1:8080/templates?template_type=parachain"

About

Playground for implementing Substrate code before it can be converted to Parachain Runtime Builder configs

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages