1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
//! # XPX Supercontracts SDK //! The documentation describe basic functions and tools //! for implementation `XPX Supercontracts` based on //! `XPX Wasm VM` (WebAssembly Virtual Machine). //! //! Currently supported target: `wasm32-unknown-unknown`. //! //! ## Development flow //! * Check is installed target: `rustup target list | grep wasm32-unknown-unknown` //! * If target not install add it: ``rustup target add wasm32-unknown-unknown //! * * Create boilerplate supercontract app: `cargo new my-supercontract` //! * Add to `Cargo.toml`: //! ```ignore //! [lib] //! crate-type = ["cdylib"] //! //! [dependencies] //! xpx_supercontracts_sdk = "0.1" //! ``` //! * Here we go! Application ready to build. To build application: `cargo build --release --target wasm32-unknown-unknown`. //! //! ## Notes //! Supercontract functions should be //! external with specific attributes: //! ```ignore //! use xpx_supercontracts_sdk::utils::{ping, debug_message}; //! //! #[no_mangle] //! pub extern "C" fn app_main() -> i64 //! ``` //! External function ay `Supercontract` //! can freely naming but with only one //! underscore symbol `_`. It's no restriction //! to number of external functions. //! External function should has directive `#[no_mangle]`. //! External function can return **only** `i64` type. //! //! Be careful with large amount of data, //! it's most expensive operation //! for `Gas` calculation. //! //! ## Examples //! //! Most simple `Supercontract` that ping `WasmVM` and //! send debug message with result to `WasmVM`. //! //! ```rust,no_run //! use xpx_supercontracts_sdk::utils::{ping, debug_message}; //! //! #[no_mangle] //! pub extern "C" fn app_main() -> i64 { //! let ping_number: usize = 99; //! let pong_result = ping(ping_number); //! let msg = format!("Supercontract Ping: {:?} and Pong: {:?}", ping_number, pong_result); //! debug_message(&msg); //! return 0; //! } //! ``` //! extern crate serde; extern crate serde_json; #[macro_use] extern crate failure; mod external; pub mod http; pub mod statuses; pub mod storage; mod tools; pub mod transactions; pub mod transactions_type; pub mod utils;