20 releases (stable)

new 2.5.0 Jan 23, 2026
2.4.0 Sep 2, 2025
2.3.1 Aug 11, 2025
2.2.0 Jul 16, 2025
0.8.1 Mar 1, 2024

#17 in #odra

Download history 30/week @ 2025-10-09 22/week @ 2025-10-16 23/week @ 2025-10-23 6/week @ 2025-11-20 19/week @ 2025-11-27 5/week @ 2025-12-04 6/week @ 2025-12-11 19/week @ 2025-12-18 25/week @ 2025-12-25 45/week @ 2026-01-01 52/week @ 2026-01-08 13/week @ 2026-01-15 31/week @ 2026-01-22

141 downloads per month
Used in 4 crates (via odra)

MIT license

510KB
12K 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::*;

#[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::Flipper;
    use odra::host::{Deployer, NoArgs};

    #[test]
    fn flipping() {
        let env = odra_test::env();
        let mut contract = Flipper::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:

  • Rust toolchain (see rustup.rs) with wasm32-unknown-unknown target.
  • cargo-odra with its dependencies (see Cargo Odra)
  • just (see just)

Run tests:

$ just test

Contact

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

Dependencies

~1–1.6MB
~29K SLoC