zink

Crates.iozink
lib.rszink
version0.1.11
sourcesrc
created_at2023-06-28 06:07:53.203882
updated_at2024-09-24 09:20:16.453465
descriptionStandard library for zink projects.
homepagehttps://github.com/clearloop/zink
repositoryhttps://github.com/clearloop/zink.git
max_upload_size
id901855
size234,377
(clearloop)

documentation

https://docs.rs/zink

README

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

Commit count: 36

cargo fmt