noir by example

nested modules

nesting modules allow for more complex package structures

in this example project,

├── Nargo.toml
└── src
   ├── foo
   │  └──

we declare the foo module in our main entrypoint

mod foo; // <-- declare the foo module

fn main(x: Field) {
    assert(foo::hello(x) != foo::bar::goodbye(x));

fn test_main() {

its implementation lives in at the same folder depth,

mod bar; // <-- declare the nested bar module

fn hello(x : Field) -> Field {

while the bar module’s implementation goes under a foo folder, inside

fn goodbye(x : Field) -> Field {
    x - 1

try it out install the noir toolchain if you haven't yet:
        curl -L | bash
        noirup --nightly
then checkout and run the example:
        git clone
        cd noir-by-example/circuits/examples/modules-nested
        nargo test --show-output

prev (modules) next (submodules)