Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

741 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Odra - Smart contracts for Casper Network.

Docs | Installation | Tutorials | Cargo Odra | Claude Code Plugin | Discord | Blog

GitHub Workflow Status Code coverage Version License Language

Table of Contents

Project Setup

This repository is the framework crate itself. You do not clone it to write contracts — you scaffold a project with Cargo Odra and depend on odra from crates.io.

# 1. Rust toolchain with the wasm target (see https://rustup.rs)
rustup target add wasm32-unknown-unknown

# 2. The project generator / build tool
cargo install cargo-odra --locked

# 3. A new project
cargo odra new --name my_project && cd my_project
cargo odra test

Full instructions, including the wasm-strip and wasm-opt prerequisites, are in the Installation guide. On Ubuntu or WSL, use Ubuntu / WSL setup — the same steps with exact commands, including the binaryen version apt is too old to give you.

Working with an AI agent

If you use Claude Code, install the Odra plugin. It teaches the agent Odra's APIs, project layout and tooling, so it scaffolds, writes, tests and deploys contracts the way this framework expects instead of guessing:

/plugin marketplace add odradev/odradev-plugins
/plugin install odra-plugin@odradev-plugins

Agents without the plugin should read https://odra.dev/llms.txt first — it is an index of the whole documentation set.

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.

About

Odra Framework

Topics

Resources

Contributing

Security policy

Stars

64 stars

Watchers

8 watching

Forks

Releases

Packages

Used by

Contributors

Languages