3 stable releases

new 2.1.0 Jul 9, 2025
2.0.1 Jun 6, 2025
2.0.0 May 27, 2025

#11 in #odra

Download history 51/week @ 2025-05-21 68/week @ 2025-05-28 120/week @ 2025-06-04 2/week @ 2025-06-11

125 downloads per month

MIT license

165KB
4K SLoC

A rust library for building command line interfaces for Odra smart contracts.

The Odra CLI is a command line interface built on top of the [clap] crate that allows users to interact with smart contracts. Traits and structs for defining custom scenarios.

A scenario is a user-defined set of actions that can be run in the Odra CLI. If you want to run a custom scenario that calls multiple entry points, you need to implement the [Scenario] and [ScenarioMetadata] traits. Traits and structs for defining deploy scripts.

In a deploy script, you can define the contracts that you want to deploy to the blockchain and write metadata to the container.


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

~24–39MB
~628K SLoC