use-ink / ink-playground

Browser Based Playground for editing, sharing & compiling ink! Smart Contracts
https://ink-playground.substrate.io
Apache License 2.0
26 stars 17 forks source link
playground rust typescript wasm webassembly

ink! Playground

⚠️ This project has been archived. It is no longer maintained.

ink! Playground

An ink! Playground which provides a Browser based IDE for editing Smart Contracts written in ink!. A live deployment of the App can be found under ink-playground.substrate.io.

Features:

Table of Contents

Getting started

On Mac-OS

Before proceeding you need to configure the following environment variables (either on your terminal or better persist them into your .zshrc file):

export PATH="/usr/local/opt/llvm/bin/:$PATH"
export CC=/usr/local/opt/llvm/bin/clang
export AR=/usr/local/opt/llvm/bin/llvm-ar

On every OS

The ink! playground is a fronted app which is developed using TypeScript and React. It is contained in the packages/playground folder.

The repo contains a Rust backend which is implemented with the actix-web framework and which can be found in the 'crates/backend' folder.

The backend serves the frontend app and it also provides the backend services for compilation and Github gists creation(which we use to provide the code sharing functionality).

To clone and build the whole project on your local computer, enter:

  1. git clone https://github.com/paritytech/ink-playground

  2. cd ink-playground

  3. make install

  4. make generate

  5. make build

Then pull and tag the docker images which are used by the backend to compile, test & format Smart Contracts:

  1. make docker-pull-images

Finally, start the backend with:

  1. make backend-run

The last command starts the Rust webserver locally on your computer. You can then access localhost:4000 from your browser to open the locally compiled ink! Playground open.

Detailed usage instructions:

The make file and ink! playground

Important commands from the make file:

crate-extractor

Overview of the (sub-)repos

We can divide this Repo into two main contributions:

The contributions of crates

The contributions of packages

This is the main Frontend Webapp which provides the ink! Playground with Rust Analyzer and compilation functionalities.

This isolates the components providing the monaco editor with integrated Rust Analyzer and the API endpoints for code compilation and Github gist creation into its own package.

Contains the basic UI building blocks. Makes use of PRIMEREACT UI library.

This is the target directory for auto generated types, files & bindings. It currently contains the change package which receives the change.json file from the crate_extractor crate and the commontypes package which carries the bindings and types which allow the Frontend (specifically the API being contained in ink-editor package) to communicate with the backend service for code compilation and Gist generation.

Based on the jest testing framework, this packages executes some basic tests against an already running playground container (serves website, provides compile endpoint).

The Dockerfiles for ink! playground

We have two Dockerfiles for two different docker images in this repo: ink-playground and ink-compiler: