14 releases (stable)

new 2.2.0 Jul 16, 2025
2.0.1 Jun 6, 2025
1.5.1 Feb 28, 2025
1.4.0 Oct 18, 2024
0.9.1 Apr 15, 2024

#5 in #odra

Download history 18/week @ 2025-04-16 8/week @ 2025-05-07 3/week @ 2025-05-14 66/week @ 2025-05-21 67/week @ 2025-05-28 126/week @ 2025-06-04 16/week @ 2025-06-11 6/week @ 2025-06-18 25/week @ 2025-06-25 10/week @ 2025-07-02 163/week @ 2025-07-09

206 downloads per month
Used in 5 crates (2 directly)

MIT license

215KB
4.5K SLoC

A module providing functionality for defining the Casper Contract Schema.

It includes traits for defining entrypoints, events, custom types, and errors, as well as functions for creating various schema elements such as arguments, entrypoints, struct members, enum variants, custom types, events, and errors.


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

~14MB
~284K SLoC