Solidity to WASM Compiler
Ethereum like smart contracts on Plasm Network.
Here is a quick demo:
Plasm Network also supports solidity. Solidity is a smart contract language mainly used on Ethereum. If you have already built applications by using Solidity, you can also deploy the contracts on Plasm Network.

Install

In this tutorial, we will use the Solang compiler, a compiler for solidity language developed by Hyperledger Labs. Let's install the compiler using the original instruction below.
Installing Solang — Solang Solidity Compiler 0.1.8 documentation
Or using the following cargo command:
1
// linux users
2
sudo apt install llvm openssl libxml2-dev
3
​
4
// mac users
5
brew install llvm openssl libxml2-dev
6
cargo install --git https://github.com/hyperledger-labs/solang --tag m8
Copied!
M1 chip macs may need to do build llvm from source:
See an example installdir or read more on the issue here​
1
git clone git://github.com/solana-labs/llvm-project
2
cd llvm-project
3
​
4
// install cmake, ninja, and any other dependencies //
5
​
6
cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On '-DLLVM_ENABLE_PROJECTS=clang;lld' \
7
-DLLVM_ENABLE_TERMINFO=Off -DCMAKE_BUILD_TYPE=Release \
8
-DCMAKE_INSTALL_PREFIX=installdir -B build llvm
9
10
cmake --build build --target install
11
​
12
//mac users do:
13
export PATH=installdir/bin:$PATH
Copied!
The solang binary should be available in your environment.

Compile

You can write any solidity contracts just like the development on Ethereum. Since this is a tutorial, we will use a flipper contract which is available below.
solang/flipper.sol at main · hyperledger-labs/solang
GitHub
Let's compile it using substrate target to make it compatible with Plasm Network.
1
wget https://raw.githubusercontent.com/hyperledger-labs/solang/master/examples/flipper.sol
2
solang flipper.sol
Copied!
As a result, two files should be available in your current directory : flipper.wasm (optimized WASM binary) and flipper.json (smart contract metadata).
If you are having trouble generating the code download it here.​

Deploy

Let's deploy the compiled flipper.contract ( this was flipper.wasm and flipper.json in previous versions) using our standard Plasm Portal UI.
Choose between ipfs or hosted apps wallet here.
Additionally you can swap between various polkadot chains including plasm, dusty, and kusama on the application depending on where you want to deploy.
select the top left corner of the site to open this tab, select the chain you want to switch to and press switch in the upper right corner.
Deploy your smart contract WASM code on Dusty Network.
The next step is to create an instance of the uploaded smart contract WASM code.
Sent smart contract instance transaction.
After making the instance, we can interact with the smart contract using the UI portal just like an ink! smart contract described in the previous chapter.
Read data from smart contract using RPC call.
Write data into smart contract via a transaction.
More examples are available in the Solang repository:
solang/examples at main · hyperledger-labs/solang
GitHub
Have fun and good luck!

Windows setup

Here you will find a tutorial:
Compile smart contracts written in Solidity for Plasm Network on Windows
Medium
​
Any questions? Feel free to ask us on our Discord tech channel. ​
Last modified 4mo ago