4 releases

new 0.9.1 Apr 15, 2024
0.9.0 Apr 2, 2024
0.8.1 Mar 1, 2024
0.8.0 Feb 6, 2024

#11 in #odra

Download history 1/week @ 2024-02-05 38/week @ 2024-02-19 130/week @ 2024-02-26 15/week @ 2024-03-04 46/week @ 2024-03-11 213/week @ 2024-04-01

261 downloads per month
Used in odra-casper-livenet-env

MIT license

215KB
4.5K SLoC

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

Use Cargo Odra to generate, build and test you code.

Example

use odra::prelude::*;
use odra::Var;

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

#[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. It shows most of Odra features.

Tests

Before running tests make sure you have following packages installed:

Run tests:

$ just test

Contact

Need some help? Write to contract@odra.dev.


lib.rs:

Casper Client implementation for Odra. It uses parts of the Casper Client implementation to communicate with Casper Node's RPC API.

Dependencies

~19–35MB
~568K SLoC