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.
- 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.
Before running this project, ensure that you have the following installed on your system:
git clone https://github.com/MVPWorkshop/ssk-substrate-playground
cd ssk-substrate-playground
cargo build
This will download all necessary dependencies, including actix-web, serde, and substrate-runtime-builder.
cargo install cargo-dotenv
To start the server, run:
cargo dotenv -e .env.local run
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.
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.
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"
}'
If the project is successfully created, you will receive the following message:
'my_project' project generated successfully.
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.
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.
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.
Endpoint: /templates
Method: GET
Fetch the all template data.
curl -X GET "http://127.0.0.1:8080/templates"
Fetch the solochain template data.
curl -X GET "http://127.0.0.1:8080/templates?template_type=solochain"
Fetch the solochain template data.
curl -X GET "http://127.0.0.1:8080/templates?template_type=parachain"