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
├── .builder_casper/
├── src/
│ ├── flipper.rs
│ └── lib.rs
├── target/
└── wasm/
Cargo.toml
Let's first take a look at Cargo.toml
file:
[package]
name = "sample"
version = "0.1.0"
edition = "2021"
[dependencies]
odra = { version = "0.3.0", default-features = false }
[features]
default = ["mock-vm"]
mock-vm = ["odra/mock-vm"]
casper = ["odra/casper"]
By default, your project will use the latest odra version available at crates.io. We are using two features:
odra/mock-vm
- it is responsible for running tests on Odra's MockVModra/casper
- backend implementation of Casper blockchain More backends will be released as features that will be possible to enable here.
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]]
name = "flipper"
fqn = "sample::Flipper"
As we can see, we have a single contract, its fqn
(Fully Qualified Name) corresponds to
the contract is located in src/flipper.rs
.
More contracts can be added here by hand, or by using cargo odra generate
command.
.builder_* folders
Those folders will be created and managed automatically by Cargo Odra. They contain project files necessary
for building wasm files and running them against blockchain VMs. As it is not necessary to modify
files in those folders in any way, by default they are hidden (hence the .
at the beginning of the
folder name).
src/
This is the folder where your smart contract files live.
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 of your choosing.
What's next
Now, let's take a look at one of the files mentioned above in more detail,
namely the Odra.toml
file.