Blanc: BLockchAiN Contract toolchain

Some of you who read my articles might know I have released the customized version of eosio.cdt, which is the comprehensive SDK for building the WebAssembly (WASM) smart contracts working on EOSIO platforms and officially provided by block.one. I called it eoscc, but now it's Blanc.

Blanc is the toolchain for WebAssembly-based blockchain contracts, and the name of "BLANC" comes from BLockchAiN Contract toolchain. Currently, Blanc supports EOSIO only, but I have a plan to support other WebAssembly-based contracts like Cosmwasm which is widely used in blockchains based on Cosmos SDK (It is well known for its consensus algorithm, Tendermint). Someday, if eWASM is adopted in Ethereum 2.0, it can belong to the scope of supported profile of Blanc.

Blanc is adapted from eosio.cdt, but has a different approach from it. The major difference between them is that eosio.cdt uses the modified version of Clang/LLVM to maximize its features, but Blanc uses the vanilla (unmodified) Clang/LLVM for easier maintenance and faster adoption of state-of-the-art technologies. Because of heavy modifications on Clang/LLVM of eosio.cdt, users should wait for block.one's updates to utilize the latest Clang/LLVM. At this point in time (January, 2021), eosio.cdt uses Clang-7 and its upcoming release uses Clang-9, but Blanc uses Clang-11. Clang-12 is under development, but you can still use it with Blanc. The only thing you need to care about is that your Clang/LLVM installed in your system supports Clang plugins and WASM binary generation. You should have Clang-11 or higher, and for MacOS, you need to install llvm Package by brew. Clang/LLVM installed by Xcode were not built for supporting plugins.

By using the latest Clang/LLVM, generated WASM binaries will have smaller size by about 10%. (eg. eosio.token 18KB → 16KB, eosio.system 276KB → 252KB) All unit tests provided by eosio.cdt and eosio.contracts are passed and all generated ABIs are identical. I lowered the version of Blanc to 0.8.0, because there remain many parts to be cleaned up, but it supports the same features of eosio.cdt v1.7.0.

When Blanc compiles C++ source code, it generates intermediate source file and its description temporarily for supporting EOSIO-specific C++11 attributes like [[eosio::action]] and generating ABI or action dispatcher. For this code generation, Blanc utilizes Clang (11 or higher) tool and plugins, and generated files will be compiled by Clang again. Blanc searches for clang++-11 from system installation path like /usr/bin in Linux, but also clang++ is set to fallback, so you can run Blanc with another version of Clang without installing Clang-11.

How to Install Blanc

Ubuntu 20.04

Install Clang/LLVM 11 from llvm.org:

bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"

Install Blanc:

bash -c "$(wget -O - https://raw.githubusercontent.com/turnpike/blanc/develop/blanc.sh)"

MacOS Big Sur

Install Clang/LLVM 11 by brew:

brew install llvm

Install Blanc:

brew tap turnpike/blanc
brew install blanc

Future work

  • Unit test framework
  • Additional default libraries
  • Contract examples in production quality
Disclaimer

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--

--

--

CEO @Haderech

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeeyong Um

Jeeyong Um

CEO @Haderech

More from Medium

Laptop open on a desk