Skip to content
/ scarab Public

Tools for working with IOTA Smart Contracts

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

l1h3r/scarab

Repository files navigation

scarab

Tools for working with IOTA Smart Contracts


Usage

fn init(ctx: &ScFuncContext) {
  let owner: ScAgentId = ctx.get_required_param("ownerParam");
  let token: ScHash = ctx.get_required_param("tokenParam");

  // ...
}

fn my_func(ctx: &ScFuncContext) {
  let data: ScHash = ctx.get_required_param("data");
  let time: i64 = ctx.timestamp();

  ctx.state().set("$time", &time);
  ctx.state().set("$data", &data);

  ctx.result("data", data);
  ctx.result("time", time);

  // ...
}

fn my_view(ctx: &ScViewContext) {
  let data: ScHash = ctx.state().get_value("$data");

  ctx.result("data", data);

  // ...
}

#[no_mangle]
fn on_load() {
  let exports = ScExports::new();
  exports.add_func("init", init);
  exports.add_func("myFunc", my_func);
  exports.add_view("myView", my_view);
}

References


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Tools for working with IOTA Smart Contracts

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages