Package Filesystem Layout
Every new blueprint package created via scrypto new-package <PACKAGE_NAME>
has the following layout of files:
├── Cargo.toml
├── src
│ └── lib.rs
└── tests
└── lib.rs
The Cargo.toml
file
Cargo.toml
is the Cargo configuration file. Cargo is the default package manager for Scrypto. It downloads all the dependencies, compiles source code, and makes a binary executable. A typical Cargo.toml
file looks like the following:
[package]
name = "test"
version = "0.1.0"
edition = "2021"
[dependencies]
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.0" }
scrypto = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.0" }
[dev-dependencies]
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "v0.4.0" }
[profile.release]
opt-level = 's' # Optimize for size.
lto = true # Enable Link Time Optimization.
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
panic = 'abort' # Abort on panic.
strip = "debuginfo" # Strip debug info.
[lib]
crate-type = ["cdylib", "lib"]
The src
Folder
The src
folder contains all the Scrypto source code for the blueprint package. Within the src
folder…
-
There must be one
lib.rs
file; -
Each other file is considered as a module and needs to be imported in
lib.rs
.
To import a module, use the mod
keyword, for example:
// Assuming you have two other files named "one.rs" and "another.rs"
mod one;
mod another;
To build your source files, run:
scrypto build
For more information about how modules work, please read this doc.
The test
Folder
The test
folder contains all the integration tests for your Scrypto package.
Different from the src
folder, you don’t have to provide a lib.rs
file. You can have multiple *.rs
files, each of which will be compiled independently.
To run all the tests, run:
scrypto test
To run all tests with a particular prefix, run:
scrypto test -- <TEST_NAME_PREFIX>
By default, test outputs will be hidden when the test passes. You can append flag -- --nocapture
to the above commands to always display output.