Structure of large smart contract

How have you envisioned the structure of big smart contracts to be?
It becomes quite hard to maintain an overview in the lib.rs file, when the contract code and test code is getting bigger and bigger

Depending on what makes sense, following what is common in Rust.
For example one common setup would be that you would have

src
    |- lib.rs
    |- types.rs
    |- impls.rs
    |- tests.rs

where, for example types.rs would define your common types, impls would implement functionality on those types, and tests.rs would contain various tests.

In lib.rs you would then just have top-level entrypoints, using functionality in impls.rs

is that what you were asking?

Okay, I was just i doubt whether a smart contract would work if there code was outside the lib.rs file. It seemed that all examples simply used only the lib.rs. But nice to know that we can just do it the common way.
Thank you for your quick reply :slight_smile:

1 Like