Skip to main content
Version: next

Directory structure

After creating a new project using Odra and running the tests, you will be presented with the following files and directories:

.
├── Cargo.lock
├── Cargo.toml
├── CHANGELOG.md
├── Odra.toml
├── README.md
├── build.rs
├── rust-toolchain
├── src/
│ ├── flipper.rs
│ └── lib.rs
├── bin/
| |── build_contract.rs
| |── build_schema.rs
| └── cli.rs
├── target/
└── wasm/
note

wasm/ only appears once you have produced wasm files - that is, after cargo odra build or cargo odra test -b casper. A plain cargo odra test runs on OdraVM and creates no wasm/ folder.

Cargo.toml​

Let's first take a look at Cargo.toml file:

[package]
name = "sample"
version = "0.1.0"
edition = "2021"

[dependencies]
odra = { version = "2.9.0", features = [], default-features = false }

[dev-dependencies]
odra-test = { version = "2.9.0", features = [], default-features = false }

[build-dependencies]
odra-build = { version = "2.9.0", features = [], default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
odra-build = { version = "2.9.0", features = [], default-features = false }
odra-cli = { version = "2.9.0", features = [], default-features = false }

[[bin]]
name = "sample_build_contract"
path = "bin/build_contract.rs"
test = false

[[bin]]
name = "sample_build_schema"
path = "bin/build_schema.rs"
test = false

[[bin]]
name = "sample_cli"
path = "bin/cli.rs"
test = false

[profile.release]
codegen-units = 1
lto = true

[profile.dev.package."*"]
opt-level = 3

By default, your project will use the latest odra version available at crates.io. For testing purposes, odra-test is also added as a dev dependency. The cfg(not(target_arch = "wasm32")) section holds the dependencies that are only needed off-chain - the build helpers and the Odra CLI - so they are not compiled into your wasm.

Odra.toml​

This is the file that holds information about contracts that will be generated when running cargo odra build and cargo odra test:

[[contracts]]
fqn = "flipper::Flipper"

As we can see, we have a single contract. Its fqn (Fully Qualified Name) is the Rust path to the contract module - here the Flipper struct in the flipper module, which lives in src/flipper.rs. More contracts can be added here by hand, or by using cargo odra generate command.

src/​

This is the folder where your smart contract files live.

build.rs​

A small build script that Odra uses to set up code generation. You don't need to touch it.

bin/​

This is the folder where scripts that will be used to generate code or schemas live. build_contract.rs and build_schema.rs are generated by cargo odra new and are used by cargo odra build, cargo odra test and cargo odra schema - you don't need to modify those. cli.rs is different: it is a starting point for your own deployment and interaction commands, and it is meant to be edited. See Odra CLI.

target/​

Files generated by cargo during the build process are put here.

wasm/​

WASM files generated by cargo odra build and cargo odra test are put here. You can grab those WASM files and deploy them on the blockchain.

What's next​

Now, let's take a look at one of the files mentioned above in more detail, namely the Odra.toml file.