Ink! Playground, Browser IDE for Substrate’s smart contract, is released
By: Task Ohmori
Tags: Substrate, Parity Substrate, Smart Contracts, Blockchain

Introduction

Stake Technologies has finished building the Ink! Playground, a browser-based IDE. Ink! is a Rust-based eDSL for writing Wasm smart contracts, which can be deployed on any Substrate-based blockchain that includes the Smart Contract pallet.

Ink! playground allows developers to compile Ink! contracts easily just by writing the code into the browser. No installation required! Our playground makes life easier for developers as it removes the need for a powerful machine or the need to keep the compiler up-to-date.

It is also possible to execute the contracts, which are compiled to Wasm bytecode. Developers no longer have to download and run Substrate locally just to test out their contracts. Ink! Playground allows anyone to write and compile the contract inside the browser.

This project was supported by a Web3 Foundation grant.

What is ink?

ink! is an eDSL to write WebAssembly based smart contracts using the Rust programming language targeting Substrate blockchains.

For further information about ink!, check the links below.

How to use ink! playground

Testing the ink! playground is easy. Here is a brief summary of the required steps:

Write ink! code directly in the browser. Compile the ink! code into WebAssembly (Wasm), a JSON metadata file is then created. Connect to a Substrate node and access to the contract module. Ink! playground also supports the Plasm chain (developed by Stake Technologies). Send your compiled code on the connected chain. Deploy the instance of the contract. Call a contract method. Test the compiled Wasm file in your local browser.

Playground instructions

The following describes each step in greater detail.

Compile ink! code

Write your ink! code into the text area on the left side, and click “COMPILE CODE” button.

You can find the example code here:

After compiling, a WebAssembly file and a metadata file are built. These can be downloaded by clicking on the respectively labelled buttons (this is optional).

Access to the Substrate chain

In order to run the code it is important to have the Wasm and metadata files inside the playground. If you compiled the code inside the playground already then you can proceed to connect to the chain. Otherwise, if you created the files locally on your machine, you will need to upload them to the playground.

To use files hosted locally press the “SELECT LOCAL” button.

Next, open the “SELECT CHAIN” tab. Choose which node you wish to connect to and click the “SET AND CONNECT” button to start connecting to the chosen Substrate node.

NOTE: See this article on how to run a local node.

https://substrate.dev/docs/en/tutorials/creating-your-first-substrate-chain/setup

If you choose “Plasm Testnet V3” in the “Default Chains” dropdown, you can connect to Plasm Testnet. If you want to connect to a local Plasm node, change the input of “ws_provider” to “ws://localhost:9944”.

Click on the “PUT CODE” button to open the popup window. Then select the Account to use, set gas limit, and set the code name (used in the web application). Once complete click the “SEND” button to send the Wasm code to the connected chain.