Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/odradev/odra

Odra framework
https://github.com/odradev/odra

framework rust smart-contracts

Last synced: 3 days ago
JSON representation

Odra framework

Awesome Lists containing this project

README

        



Odra - Smart contracts for Casper Network.



Docs |
Installation |
Tutorials |
Cargo Odra |
Discord |
Blog




GitHub Workflow Status


Code coverage


Version


License

Language


## Table of Contents
- [Usage](#usage)
- [Example](#example)
- [Tests](#tests)
- [Links](#links)
- [Contact](#contact)

## Usage

Use [Cargo Odra](https://github.com/odradev/cargo-odra) to generate, build and test you code.



## Example

```rust
use odra::prelude::*;
use odra::Var;

#[odra::module]
pub struct Flipper {
value: Var,
}

#[odra::module]
impl Flipper {
pub fn init(&mut self) {
self.value.set(false);
}

pub fn set(&mut self, value: bool) {
self.value.set(value);
}

pub fn flip(&mut self) {
self.value.set(!self.get());
}

pub fn get(&self) -> bool {
self.value.get_or_default()
}
}

#[cfg(test)]
mod tests {
use crate::flipper::FlipperHostRef;
use odra::host::{Deployer, NoArgs};

#[test]
fn flipping() {
let env = odra_test::env();
let mut contract = FlipperHostRef::deploy(&env, NoArgs);
assert!(!contract.get());
contract.flip();
assert!(contract.get());
}
}
```

Checkout our [examples](https://github.com/odradev/odra/tree/HEAD/examples).
It shows most of Odra features.

## Tests

Before running tests make sure you have following packages installed:

- Rust toolchain (see [rustup.rs](https://rustup.rs/)) with `wasm32-unknown-unknown` target.
- `cargo-odra` (see [Cargo Odra](https://github.com/odradev/cargo-odra))
- `just` (see [just](https://github.com/casey/just#packages))

Run tests:

```bash
$ just test
```

## Links

* [Odra Book - Docs and Tutorials](https://odra.dev/docs)
* [API Documentation](https://docs.rs/odra/latest/odra/)
* [Cargo Odra](https://github.com/odradev/cargo-odra)
* [Example Contracts](https://github.com/odradev/odra/tree/HEAD/examples)

## Contact
Need some help? Write to **[email protected]**.


by odra.dev