The goal of this project is to increase and accelerate the adoption of blockchain technology.
Through this solution, developers will be able to automatically generate entire React.js dApps starting from the ABI of smart contracts; those, in order to be compatible with this solution, must be written in Rust, using the MultiversX framework.
The dApp will be configured with the libraries made available by the MultiversX team to facilitate the interactions with the blockchain and smart contracts.
A Proof of Concept has already been developed as my graduation project. This POC is very limited as it allows the generation of dApps from relatively simple smart contracts; for example, the POC version covers only the Rust and framework basic types, completely ignoring custom types defined via struct or enums.
Another limitation is that the generated components are not assembled; this means, that the programmer has to assemble the components based on how they interact with each other.
For the participation in the hackathon, the development of the project started again from 0 sever times, but the final version is represented by this repository. We started from scratch again, with the goal to fix some bugs present in the POC version and, most importantly, to allow proper implementation of the limitations described above.
Thus, the final version will be more versatile and will be compatible with a greater variance of smart contracts.
Demo | Bug(label: bug) | Feature(label: enhancement)
- 📐 Architecture
- 🖥️ Getting started
- 🛠 How to
- ✅ Todo
- 👥 Contribute
- 📑 License
- JavaScript runtime node.js;
- Rust toolchain rustup, rustc, cargo;
- OPTIONAL:
- Alternative package manager:
- cargo-watch:
cargo install cargo-watch;
-
Get the repository:
git clone https://github.com/doinel1a/gen-x; -
Open your terminal or code editor to the path the project is located, and run:
-
In the root
/folder:npm pnpm yarn To install the dependencies npm installpnpm installyarn install -
In the
front-endfolder:npm pnpm yarn To install the dependencies npm installpnpm installyarn installTo run the development server * npm run devpnpm devyarn devTo build the app for production npm run buildpnpm buildyarn buildTo preview the production optimized app * npm run previewpnpm previewyarn preview* The front-end interface will be accessible at the following url:
http://localhost:3000. -
In the
back-endfolder:Cargo To run the back-end in development mode * cargo runTo run the back-end in development & watch mode * cargo watch -x "run"To run the back-end in production mode * cargo run --releaseTo build the back-end for production cargo build --release*
The API will be accessible at the following url:http://localhost:8080.
The available endpoints are:- /api/v1/healthcheck
- /api/v1/generate
-
To test the solution:
-
Cloud:
- In your favourite API client:
- Set the HTTP Method to
POST; - Set the url as
https://gen-x-back-end.fly.dev/api/v1/generate; - Select
Bodyand thenJSON; - Insert a JSON which must have the following structure:
To enable the rendering feature of a endpoint inside a specific page, insert in the documentation of each endpoint a field like
{ "sc_address": "", "sc_abi": { "name": "SC name", "constructor": { "inputs": [ . . . ], "outputs": [ . . . ] }, "endpoints": [ . . . ], "events": [ . . . ] , "hasCallback": false, "types": { . . . } } }path: /pages/page1; otherwise it will be rendered in its predefined folder
- Set the HTTP Method to
- Send request;
- Download .zip project;
- In your favourite API client:
-
Locally:
- Get started;
- Build and run the API;
- In your favourite API client:
- Set the HTTP Method to
POST; - Set the url as
http://localhost:8080/api/v1/generate; - Select
Bodyand thenJSON; - Insert a JSON which must have the following structure:
To enable the rendering feature of a endpoint inside a specific page, insert in the documentation of each endpoint a field like{ "sc_address": "", "sc_abi": { "name": "SC name", "constructor": { "inputs": [ . . . ], "outputs": [ . . . ] }, "endpoints": [ . . . ], "events": [ . . . ] , "hasCallback": false, "types": { . . . } } }path: /pages/page1; otherwise it will be rendered in its predefined folder - Set the HTTP Method to
- Send request;
- Download .zip project;
- Front-end:
- Integrate API:
- Display back-end errors in the UI;
- Integrate API:
- Back-end:
- Test generate endpoint to download .zip archive;
- Set listen address dynamically based on the environment;
- Smart contract ABI:
- Address:
- Validation;
- Endpoints:
- Readonly:
- Render single endpoint w/ its inputs & outputs;
- Render all endpoints;
- Render & "assemble" endpoints in the specified page;
To enable this feature, insert in the documentation of each endpoint a field likepath: /pages/page1 - Handle custom types - Struct & Enum:
- Input serialization:
- Base Rust types;
- Struct;
- Enums (only rendering);
- Output deserialization:
- Base Rust types;
- Struct;
- Enums (only rendering);
- Input serialization:
- Mutable:
- Render single endpoint w/ its inputs & outputs;
- Render all endpoints;
- Render & "assemble" endpoints in the specified page;
To enable this feature, insert in the documentation of each endpoint a field like
path: /pages/page1 - Handle custom types - Struct & Enum:
- Input serialization:
- Base Rust types;
- Struct;
- Enums (only rendering);
- Output deserialization:
- Base Rust types;
- Struct;
- Enums (only rendering);
- Input serialization:
- Readonly:
- Custom types:
- Struct;
- Enum;
- Address:
- Fix MultiversX sdk UI styling;
- Update dApp boilerplate to the last version;
- CI / CD:
- Deploy front-end (vercel);
- Deploy back-end (fly.io);
- Set-up Docker;
- Optimize Docker image size;
- CI / CD github actions;
- Trigger vercel deployments only on front-end folder push;
(git diff --quiet HEAD^ HEAD -- .in git project settings;.sincefront-endis setted as root directory) - Trigger fly.io deployments, through gh actions, only on back-end folder push;
Contributions are what make the open source community such an amazing place to learn, inspire, and create.
Any contribution is greatly appreciated: big or small, it can be documentation updates, adding new features or something bigger.
Please check the contributing guide for details on how to help out and keep in mind that all commits must follow the conventional commit format.
- Get started;
- For a new feature:
- Create a new branch:
git checkout -b feat/NEW-FEATURE; - Add your changes to the staging area:
git add PATH/TO/FILENAME.EXTENSION; - Commit your changes:
git commit -m "feat: NEW FEATURE"; - Push your new branch:
git push origin feat/NEW-FEATURE;
- Create a new branch:
- For a bug fix:
- Create a new branch:
git checkout -b fix/BUG-FIX; - Add your changes to the staging area:
git add PATH/TO/FILENAME.EXTENSION; - Commit your changes:
git commit -m "fix: BUG FIX"; - Push your new branch:
git push origin fix/BUG-FIX;
- Create a new branch:
- Open a new pull request;
All logos and trademarks are the property of their respective owners.
Everything else is distributed under the GPL-3.0 License.
See the LICENSE file for more informations.