Giter Site home page Giter Site logo

newbie-teen / soll Goto Github PK

View Code? Open in Web Editor NEW

This project forked from multiversx/soll

0.0 0.0 0.0 9.65 MB

SOLL is a new compiler for generate Ewasm from solidity and yul. See a demo here: https://youtu.be/X-A6sP_HTy0

Home Page: https://www.secondstate.io/

Shell 0.42% C++ 97.89% Python 0.08% C 0.01% CMake 1.60%

soll's Introduction

1. Introduction

SOLL is a new compiler for generating Ewasm (Ethereum flavored WebAssembly) files from Solidity and Yul.

To support developers as many as possible, we design projects to not only support more smart contract programming languages, such as Rust and C++, but also support various VMs, such as Ewasm VM and evm. To achieve this goal, in the very first step, we develop SOLL, a compiler for Solidity-based smart contract running on Ewasm VM.

SOLL has two phases in the code generation flow. Generate LLVM IR files first, then leverage LLVM framework to generate Ewasm bytecode.

For application users, please refer to this document. You will know how to use SOLL to generate Ewasm bytecode from your Solidity smart contract or Yul language, and then deploy the Ewasm bytecode to Ethereum Ewasm TestNet.

For developers, we provide another document for explaining the design of SOLL and how to develop and test the functionality of SOLL, please refer to the Developer Guide for more details.

2. Current Status and Limitations

SOLL is still in early stage, and we’ve not fully supported Solidity and Yul. Please check features we’ve done and limitations in the following documents.

And SOLL integrates Solidity and Yul test contracts from ethereum/solidity.

Here is the pass rate of both language:

Solidity test suite (Total 75 tests from compilationTests):

Expected Passes    : 22 # Solidity has 75 testing contract, and SOLL can pass 22.
Unsupported Tests  : 53 # Unimplemented by SOLL
Pass Rate: 29%

Yul test suite (Total 499 tests from libyul):

Expected Passes    : 293 # libyul has 499 testing contracts, and SOLL can pass 293.
Unsupported Tests  : 206 # Unimplemented by SOLL
Pass Rate: 59%

3. Getting Started

To get started with our demonstration, you will need prepare two components at first.

We provide an image include build and execute environment (recommend). If you don't want to use docker directly you will need below tools (cmake, llvm, xxd, wabt, node.js).

3.1 Preparation

  • Pull official docker image to get an already established build/execute environment.
> docker pull secondstate/soll
  • Get Source Code from Github and checkout to the latest version, 0.0.5.
> git clone --recursive https://github.com/second-state/soll.git
> cd soll
> git checkout 0.0.5

3.2 Launch Environment

Attach shell to container and bind volume with repositories' path.

> docker run -it --rm \
      -v $(pwd)/soll:/root/soll \
      secondstate/soll

3.3 Build SOLL

Build SOLL(we use cmake with llvm library)

(docker) $ cd ~/soll && mkdir -p build && cd build
(docker) $ cmake .. && make

3.4 Compile an ERC20 smart contract

As above-mentioned, to compile Solidity Smart Contract code, SOLL will generate LLVM IR files(.ll), and then generate Ewasm bytecode(.wasm).

Phase 1. Use SOLL generate LLVM IR files(.ll) from the ERC20 contract

Create your smart contract files by copying from our demonstration contract "0-0-3.sol".

(docker) $ cd ~
(docker) $ cp ~/soll/doc/examples/0-0-3.sol ~/contract.sol

Execute SOLL to generate a LLVM IR file(.ll) for the next step.

(docker) $ ~/soll/build/tools/soll/soll contract.sol > contract.ll

Phase 2. Generate Ewasm bytecode(.wasm) from a LLVM IR file

(docker) $ ~/soll/utils/compile -v contract.ll

After compiling "contract.ll", SOLL compiler will generate two files:

  1. "contract.deploy.wasm": Contract bytecode with deployer. Use this for the deployment.
  2. "contract.wasm": Contract runtime bytecode only. You can execute it with Ewasm runtime directly.

We will use "contract.deploy.wasm" in the next section to deploy it to Ewasm TestNet.

3.5 Deploy an ERC20 smart contract to Ewasm TestNet

Step 1: Convert Wasm files to Hex Code files.

To deploy our smart contract to TestNet, we need to convert the WASM files to Hex Code files.

(docker) $ xxd -p contract.deploy.wasm | tr -d $'\n'

Step 2: Submit the Hex Code files to Ewasm TestNet.

Copy the Hex Code generated by the previous step.

Find ToolsSubmitTx

Paste the Hex Code to Ewasm TestNet website and submit it.

Paste the Hex Code and submit it

Submit the Hex Code to Ewasm TestNet.

Submiting the Hex Code

Step 3: Check activities of TestNet to make sure our contracts executed successfully.

Check whether the latest activity is our contract or not.

Check the latest activity Check the latest transaction

Check the Bytecode of the latest activity.

Check the bytecode

Check the Ewasm code of the latest activity.

Check the Ewasm code

Check the Storage part of the latest activity.

Check the Storage

Congratulations! Now you finished our user tutorial.

soll's People

Contributors

captainvincent avatar 0yi0 avatar ibmibmibm avatar hydai avatar redleaf23477 avatar totoroxd avatar dm4 avatar jacky860226 avatar peter-chang avatar tpmccallum avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.