# Odra Principles
> "Design for professionals with deadlines." - Socrates
Odra is a set of tools and libraries for the Casper ecosystem. It is a complete
solution to develop, test, build, deploy and interact with deployed smart
contracts for Casper.
Key principles are:
- developer-first approach with compact syntax,
- fast code/build/test cycle,
- code reusability,
- testability,
- ease of integration.
## Developing Contracts
> "Best code is no code at all." - Alexander The Great
One of the goal of every developer is writing compact code. The less code
exists, the less bugs there is. It is easier to reason about small codebase.
Maintaining and extending small codebase is easier. It is easier (and cheaper)
to audit the code.
Odra is build around the concept of modules that executes in an isolated
environment. Modules can be composed into bigger modules. Modules are the unit
of code that can be reused across projects. This logical separation helps
multiple developers to work on the same project and don't loose efficiency,
because modules composability and interfaces is enforced by the Odra's design.
Reusability is a key factor in growing the ecosystem. The more reusable code
there is, the more complex systems can be build in a shorter time. It is the
key reason why Solidity became so popular.
Rust is a great language for writing smart contracts. It is a modern, strongly
typed language with great tooling. At its core enables writing fast and secure
code. We say in Rust community: "Rust compiler is your best friend". Odra
provides Rust libraries that don't confuse everyday Rust developer.
Learning curve is also a factor in growing the ecosystem. Simpler tools are
easier to learn and master. To write smart contracts with Odra, developer
needs to know basic Rust. Odra doesn't require lifetimes or generics. It
abstracts the whole storage and environment interaction with compact and sound
API.
Most of smart contract developers uses similar design patterns to define
access control, complex storage structures, and (non)fungible tokens. Odra
provides a set of reusable modules that aims at standardizing contract
interfaces and provides well written implementations of most popular ones.
## Testing
> "Your code is as good as restrictive its tests are." - Rick Sanchez
Before Odra there was no way to quickly run large integration tests. That was
the largest time bottleneck in the whole development cycle. While testing all
the developer can do is wait. To meet fast cycle requirement we provide two
testing modes: quick but not restrictive and slow but restrictive. For
everyday programming, developers uses quick mode that in a medium size project
takes less than 10 seconds. For final testing, developers uses slow mode that
can take long minutes.
Odra provides a testing environment where it is easy to instantiate stateful
contracts, interact with them, change caller context, handle native CSPR token
and advance block time when running time-based scenarios.
Tests are often the only definition of the system behavior. In all commercial
projects, developer realize the concept of non-technical product owner. This
person is responsible for explaining the system behavior to a developer, so
he/she knows what to build. BDD-style testing is a great tool for both the
developer and the product owner. Owner can write down the system behavior in
English using Gherkin syntax. Then developer can run Gherkin tests against the
contract implementation. Odra is compatible with such a workflow.
## Building
> "Smart contract code is used on-chain and off-chain." - Charles Darwin
Even the best code can be slow and unsecure if it is not properly compiled.
Odra makes this heavy lifting for the developer. It is unreasonable to expect
that everyone can have sufficient knowledge to properly optimize the
compilation process. For the Rust to WASM compilation, Odra automatically
applies all the best practices that exists for building the most efficient
WASM binaries. Yet, it is a moving target. Odra Team is constantly monitoring
the WASM ecosystem, tests new compilation techniques and applies them to the
Odra build process in subsequent releases. It greatly reduces the amount of
work, that developer has to spend on exploring that matter. Many of Odra
design decisions are driven by the requirements of the WASM compilation
process.
When building Odra module into a WASM binary for Casper blockchain, the WASM
binary needs to be constructed in a very specific way. It is closely related
to the Casper Execution Engine (EE) specification. That spans from the
installation of a smart contract, defining entrypoints, handle Casper-style
upgrades all the way to how data is stored and indexed on blockchain. It is
not that difficult to make it right, but it is quite significant amount of
work to do. Odra is an abstraction on top of EE's specification and provides
API that handles above nuances for a developer and guarantees basic level of
security of smart contracts.
Odra also leverages the fact that Rust is general purpose language. It allows
to provide API for using a smart contract code in the off-chain environments.
These are: local tests, blockchain client code and fronted code. The last one
is achieved by compiling Rust code into WASM binary (different then the WASM
for the blockchain) and running it in the browser. Another possibility is
using Odra code in ZK proofs via RiscZero or zkWASM.
Odra produces fast code, by providing gas-optimized interface to the host
virtual machine.
## On-chain contracts
> "Integration with the system often, takes more time, then building one." - Bogdan Węglorz
Developing smart contracts is only the first step. The next one is deploying
to the blockchain. Any WASM binary built with Odra provides a standardized
method for installing smart contract on the Casper blockchain. It gives full
control over the smart contract initialization process. It forces a developer
to be explicit about upgradability, initialization and discoverability. A
developer can choose between three main ways of interacting with the contract,
depending on the need. `casper-client` and `cargo-odra` can be used in CLI
environment. For the Rust environment, Odra provides convinient API for
interacting with smart contracts. It uses developer-defined code as a client
and enables to write short programs. For the browser environment, Odra
provides a WASM-based JS client. Integration with a smart contract is often a
significant part of the whole project, so Odra aims at making that process as
easy as possible.