odra-casper-livenet-env

Crates.ioodra-casper-livenet-env
lib.rsodra-casper-livenet-env
version2.5.0
created_at2024-02-06 14:49:53.716184+00
updated_at2026-01-23 10:43:13.34757+00
descriptionOdra's backend for interacting with the Casper Node.
homepagehttps://odra.dev/docs
repositoryhttps://github.com/odradev/odra
max_upload_size
id1128999
size118,414
Krzysztof Pobiarżyn (kpob)

documentation

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

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

Links

Contact

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

by odra.dev
Commit count: 301

cargo fmt