Compiling Zink Project

We have got a zink project after creating-zink-project, now it’s time to compile it to EVM bytecode!

# Enter our project
cd my-awesome-project

# Build the project
elko build

# Check the outputs
ls target/zink
my-awesome-project.wasm my-awesome-project.bin

you’ll see a my-awesome-project.bin file under target/zink, and that’s it!

How it works?

first, elko compiles the cargo project to WASM with:

cargo b --target wasm32-unknown-unknown --release

then, there will be some logic inside elko, running wasm-opt for our output WASM binary

# if you have wasm-opt installed on your machine, you can try the same
mkdir -p target/zink
wasm-opt -O4 target/wasm32-unknown/unknown/release/my-awesome-project.wasm -o target/zink/my-awesome-project.wasm

finally we use zinkc to compile the wasm to EVM bytecode:

# For reproducing it in your command line
zinkc target/zink/my-awesome-project.wasm
mv my-awesome-project.bin target/zink

Future plans (TODO)

  1. Generate the ABI as well.
  2. Add command for deploying the bytecode to EVM chain with RPC endpoints.
  3. Test suite