Show the crate…

17 releases

0.1.11 Sep 24, 2024
0.1.10 Dec 28, 2023
0.1.7 Nov 30, 2023
0.1.5 Oct 27, 2023
0.0.1 Jun 28, 2023

#21 in #nova


Used in zinkup

GPL-3.0-only

73KB
275 lines

Zink

The standard library for zink projects.

//! Addition example.
#![cfg_attr(target_arch = "wasm32", no_std)]
#![cfg_attr(target_arch = "wasm32", no_main)]
extern crate zink;

/// Adds two numbers together.
#[zink::external]
pub fn addition(x: u64, y: u64) -> u64 {
    x + y
}

#[cfg(not(target_arch = "wasm32"))]
fn main() {}

#[test]
fn test() -> anyhow::Result<()> {
    use zint::{Bytes32, Contract};
    let mut contract = Contract::search("addition")?.compile()?;

    let info = contract.execute([
        "addition(u64,u64)".as_bytes(),
        &1u64.to_bytes32(),
        &2u64.to_bytes32(),
    ])?;
    assert_eq!(info.ret, 3u64.to_bytes32());

    Ok(())
}

LICENSE

GPL-3.0


lib.rs:

Zink library for developing smart contracts for blockchains.

Dependencies

~0.4–1MB
~23K SLoC