Skip to content
 
 

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust SDK for Alphabill predicates

This is experimental / work-in-progress SDK for creating custom predicates for Alphabill using Rust.

To see the documentation of the SDK run

cargo doc --all-features

in the repository root and open the generated doc in a web browser.

Quick Start

The cargo-generate tool can be used to create predicate project from template:

cargo-generate generate --git https://github.com/alphabill-org/alphabill-rust-predicates-sdk template

Predicates

Predicate project should be "library" project with

crate-type = ["cdylib"]

and export function(s) with signature

#[unsafe(no_mangle)]
pub extern "C" fn predicate_name() -> u64 {
}

Return value should follow convention:

  • 0: predicate evaluated to "true";
  • 1: predicate evaluated to "false";
  • any other value is considered to be "error code" (ie predicate failed);

SDK provides predicate_result macro which should be used to encode the result of the predicate.

Create WASM binary

Compile the predicate into WASM binary

cargo build --release --target wasm32-unknown-unknown

Create Alphabill predicate

Use Alhpabill CLI wallet tool to wrap the WASM binary into Alphabill predicate usable with Alphabill units.

About

Rust SDK for writing Alphabill predicates

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages