Crates.io | zink |
lib.rs | zink |
version | 0.1.10 |
source | src |
created_at | 2023-06-28 06:07:53.203882 |
updated_at | 2023-12-28 11:38:50.167218 |
description | Standard library for zink projects. |
homepage | https://github.com/clearloop/zink |
repository | https://github.com/clearloop/zink.git |
max_upload_size | |
id | 901855 |
size | 211,925 |
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(())
}
GPL-3.0