8 releases

0.1.10 Dec 28, 2023
0.1.9 Dec 23, 2023
0.1.7 Nov 30, 2023
0.1.5 Oct 27, 2023

#49 in #evm

Download history 2/week @ 2023-12-17 2/week @ 2023-12-24 13/week @ 2024-02-25 117/week @ 2024-03-31

117 downloads per month
Used in zink

GPL-3.0-only

23KB
684 lines

The Zink Project

[!CAUTION]

This project is still under active development, plz DO NOT use it in production.

zink ci telegram

The Zink project mainly provides a singlepass compiler zinkc which compiles WASM to EVM bytecode, the source code of your smart contracts could be any language you like!

flowchart LR
    R{{Rust}} --> W(WebAssembly)
    O[...] --> W
    W --> Z{Zink Compiler}
    Z --> V[(EVM)]

Here we highly recommend you to choose rust as the language of your smart contracts which will unlock all of the following features:

  • Safe: rustc is watching you! Furthermore, after compiling your rust code to WASM, zinkc will precompute all of the stack and memory usage in your contracts to ensure they are safe in EVM bytecode as well!

  • High Performance: The optimizations are provided by the three of rustc, wasm-opt and zinkc, your contracts will have the smallest size with strong performance in EVM bytecode at the end!

  • Compatible: All of the no_std libraries in rust are your libraries, you can use your solidity contracts as part of your zink contracts and your zink contracts as part of your solidity contracts :)

  • Easy Debugging: Developing your smart contracts with only one programming language! zink will provide everything you need for developing your contracts officially based on the stable projects in rust like the foundry tools.

Run cargo install zinkup to install the toolchain!

Fibonacci Example

fib(n) Zink Solidity@0.8.21
0 110 614
1 110 614
2 262 1322
3 414 2030
4 718 3446
5 1174 5570
/// Calculates the nth fibonacci number using recursion.
#[no_mangle]
pub extern "C" fn recursion(n: usize) -> usize {
    if n < 2 {
        n
    } else {
        recursion(n - 1) + recursion(n - 2)
    }
}

As an example for the benchmark, calculating fibonacci sequence with recursion, missed vyper because it doesn't support recursion...Zink is 5x fast on this, but it is mainly caused by our current implementation is not completed yet ( missing logic to adapt to more situations ), let's keep tuned for v0.3.0.

LICENSE

GPL-3.0-only


lib.rs:

Zink filetests

Dependencies

~0.1–2.8MB
~43K SLoC