How to run a Substrate SSVM Node
Tutorial on how to run a SSVM node on ParaState
The primary objective of this project was to bring the Ethereum flavored WebAssembly (EWASM) runtime to Substrate. It enables developer collaboration between the Ethereum and Polkadot/Substrate ecosystems, and promotes inter-blockchain interoperability at the application level. You can now create a Substrate node (or Polkadot parachain) that supports the deployment and execution of EWASM smart contracts.
For the full documentation on the project refer to the ParaState GitHub page.
Getting Started
In this tutorial we will build and interact with the SSVM Node.
Please refer to the GitHub for more info.
I am using Ubuntu 20.04.
1. Install docker
In order to build and run a node we will need the Substrate SSVM.
The Substrate SSVM is provided in a docker image.
The Docker official documentation will show you how to install docker.
https://docs.docker.com/engine/install/ubuntu/
2. Download the docker image
After installing docker we can simply pull the image:
docker pull secondstate/substrate-ssvm
3. Build and run a node
Now that the environment is ready we can:
- Download the source code of the node from GitHub
- git clone https://github.com/second-state/substrate-ssvm-node.git
2. Run the docker image with the substrate SSVM:
docker run -it — rm \
— name substrate-ssvm \
-v $(pwd):/root/node \
-w /root/node \
-p 9944:9944 \
secondstate/substrate-ssvm
It is important to publish the ports from the container so that we can interact with the node using the Substrate web UI.
Note that at this point we will be inside the docker container:
3. Step into the “substrate-ssvm-node” folder:
cd substrate-ssvm-node
3. Build:
* make init
* make build
4. Run:
cargo run — release — bin ssvm-node — — dev — ws-external
If everything is working you will see this output from the node:
4. Connect tothe node
If everything went fine we should have an ssvm node running and we should be able to interact with it using the Substrate Web UI.
Note we assume the node is running on the same machine where you will open the browser.
Let’s see how:
- Open the https://polkadot.js.org/apps
Go to settings -> development and choose local node
2. Click on switch and you are connected:
5. Interact with the node
Now that we are connected to our local node we can interact with it.
Let’s create a contract:
We we will use this as example: erc20.hex.
From the tab Developer:
- Go to Extrinsics, select
ssvm
andcreate
2. Put the content of erc20.hex in the code
section
3. Gas limit: 5000000
4. Gas price: 1
5. Submit the transaction
Here the result:
We can see the contract deployed from Network -> Explorer.
We will see a new recent event (Our contract created!!!)
Now we can interact with the contract. For example we can query the balances from Alice.
Here is how to do it:
1. Prepare call data:
In EVM, call data is in
{function signature}{function arguments}
formatData of
balanceOf(Alice)
is0x70a082310000000000000000000000009621dde636de098b43efb0fa9b61facfe328f99d
2. Copy the contract address from the recent event.
Let’s go back in the extrinsics tab (Developer -> Extrinsics).
1. In Extrinsics, select ssvm
and call
.
2. Fill contract address (in my example: 0x5801b439a678d9d3a68b8019da6a4abfa507de11) in target section.
3. Fill call data in input section.
4. Gas limit: 5000000
5. Gas price: 1
6. Submit the transaction
From the recent events in the Network -> Explorer tab you will see the call and the output.
From the Blocks details tab we can also see more information
This is how you interact with the node, deploy smart contracts and if you want to learn more please visit this page for more tutorials: https://github.com/ParaState/substrate-ssvm-node/blob/master/docs/interact-using-web.md
If you find any problem contact the ParaState team and they will provide all the help you need.