Odra: A New Smart Contract Standard for Casper

OdraDev and Casper Association are proud to announce Odra 1.0, a complete solution to develop, test, build, deploy, and interact with smart contracts on Casper.

Rapid Development

Odra is designed with the main focus on optimizing the development time, it manifests in a fast code/build/test cycle, code reusability, testability, and ease of integration. Compared to existing tools, Odra results in up to 80% gains in efficiency, leaving more time for developers to focus on things that matter, like business logic, security, and user experience, rather than on the tooling, configuration, and boilerplate code. Odra is well-documented and full of examples. See https://odra.dev/docs.

Lego Bricks

Code reusability is a key factor in growing the ecosystem. The more reusable code there is, the more complex systems can be built in a shorter time. This is a key reason why Solidity became so popular and why Ethereum flourished. Odra is built around the concept of reusable modules. Just like Lego bricks, these modules can be composed into bigger and more complex systems. With a set of reusable modules, Odra allows developers to start with a full toolbox from day one. Odra includes complete implementations of Access Control, ERC20, ERC721, ERC1155, CEP18, and CEP78.

Example

Here is an example of a simple Counter contract written in Odra. In just 30 lines of code, the contract is implemented and tested.

use odra::{Var, prelude::*};

#[odra::module]
pub struct Counter {
   value: Var<u32>,
}

#[odra::module]
impl Counter {
   pub fn get_count(&self) -> u32 {
       self.value.get_or_default()
   }

   pub fn increment(&mut self) {
       self.value.set(self.get_count() + 1);
   }
}

#[cfg(test)]
mod tests {
   use super::*;
   use odra::host::{Deployer, NoArgs};

   #[test]
   fn flipping() {
       let env = odra_test::env();
       let mut contract = CounterHostRef::deploy(&env, NoArgs);
       assert_eq!(contract.get_count(), 0);
       contract.increment();
       assert_eq!(contract.get_count(), 1);
   }
}

What is even better, Odra allows interacting with the live networks from within the code. What is revolutionary the developer doesn't have to deal with querying the storage manually anymore.

use counter::CounterHostRef;
use odra::host::{Deployer, NoArgs};

fn main() {
   let env = odra_casper_livenet_env::env();
   
   env.set_gas(300_000_000_000u64);
   let mut contract = CounterHostRef::deploy(&env, NoArgs);
   
   env.set_gas(1_000_000_000u64);
   contract.increment();
   
   env.set_gas(1_000_000_000u64);
   let count = contract.get_count();
   assert_eq!(count, 1);
}

Code, Documentation and Tutorials

Odra is an open source project and ships with full documentation and a lot of practical tutorials.

If you are a developer, leave us a star on GitHub. Join the Odra Discord to get support and follow Twitter to stay up to date.

What's Next

Casper Network is changing fast. The Condor release is just around the corner, and Odra will be ready, so developers can focus on building the next generation of Casper smart contracts. OdraDev doesn't stop here. The next features are already in the pipeline. Stay tuned.