Crates.io | blockless-sdk |
lib.rs | blockless-sdk |
version | 0.1.5 |
source | src |
created_at | 2023-06-17 00:45:52.988281 |
updated_at | 2024-10-07 04:18:32.574249 |
description | blockless runtime sdk |
homepage | |
repository | https://github.com/blocklessnetwork/sdk-rust |
max_upload_size | |
id | 892637 |
size | 57,158 |
Install the rust with rustup, please visit the site 'https://rustup.rs/'.
Use follow command for build the project.
$ cargo build
HTTP example
use blockless_sdk::*;
use json;
fn main() {
let opts = HttpOptions::new("GET", 30, 10);
let http = BlocklessHttp::open("https://demo.bls.dev/tokens", &opts);
let http = http.unwrap();
let body = http.get_all_body().unwrap();
let body = String::from_utf8(body).unwrap();
let tokens = match json::parse(&body).unwrap() {
json::JsonValue::Object(o) => o,
_ => panic!("must be object"),
};
let tokens = match tokens.get("tokens") {
Some(json::JsonValue::Array(tokens)) => tokens,
_ => panic!("must be array"),
};
tokens.iter().for_each(|s| {
println!("{:?}", s.as_str());
});
}
Examples are in the examples
directory.
# Build example
cargo build --release --target wasm32-wasi --example coingecko_oracle
# Run example with blockless runtime
echo "bitcoin" | runtime target/wasm32-wasi/release/examples/coingecko_oracle.wasm --permission https://api.coingecko.com/
# Build example
cargo build --release --target wasm32-wasi --example httpbin
# Run example with blockless runtime
runtime target/wasm32-wasi/release/examples/httpbin.wasm --permission http://httpbin.org/anything