https://github.com/l1h3r/scarab
Tools for working with IOTA Smart Contracts
https://github.com/l1h3r/scarab
iota smart-contract smartcontracts webassembly
Last synced: about 1 year ago
JSON representation
Tools for working with IOTA Smart Contracts
- Host: GitHub
- URL: https://github.com/l1h3r/scarab
- Owner: l1h3r
- License: apache-2.0
- Created: 2021-03-07T18:58:49.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-07T05:11:38.000Z (about 5 years ago)
- Last Synced: 2025-03-22T07:23:04.612Z (about 1 year ago)
- Topics: iota, smart-contract, smartcontracts, webassembly
- Language: Rust
- Homepage:
- Size: 108 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# scarab
**Tools for working with IOTA Smart Contracts**
---
## Usage
```rust
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
* [Wasp](https://github.com/iotaledger/wasp)
* [WasmLib](https://github.com/iotaledger/wasp/tree/master/contracts/rust/wasmlib)
#### 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.