Skip to content

odradev/odra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ce9e48d · Feb 28, 2025
Sep 20, 2024
May 27, 2024
Feb 28, 2025
Feb 28, 2025
Feb 28, 2025
Feb 28, 2025
Jun 5, 2024
Feb 28, 2025
Feb 28, 2025
Feb 28, 2025
Oct 18, 2024
Feb 26, 2024
Feb 28, 2025
Oct 18, 2024
Feb 28, 2025
Feb 16, 2024
Feb 28, 2025
Jan 7, 2025
May 22, 2023
Feb 28, 2025
May 25, 2022
May 27, 2024
May 20, 2024
Sep 27, 2022
Oct 18, 2024
Apr 2, 2024
Feb 28, 2025
Mar 28, 2024

Repository files navigation

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

Links

Contact

Need some help? Write to [email protected].