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-featuresin the repository root and open the generated doc in a web browser.
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 templatePredicate 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.
Compile the predicate into WASM binary
cargo build --release --target wasm32-unknown-unknownUse Alhpabill CLI wallet tool to wrap the WASM binary into Alphabill predicate usable with Alphabill units.