Skip to main content
Version: 5.x


What it does

Checks if a contract is annotated with the no_main inner attribute.

Why is this necessary?

Contracts must be annotated with no_main inner attribute when compiled for on-chain execution.


// Bad: Contract does not contain the `no_main` attribute,
// so it cannot be compiled to Wasm
#![cfg_attr(not(feature = "std"), no_std)]
mod my_contract { /* ... */ }

Use instead:

#![cfg_attr(not(feature = "std"), no_std, no_main)]
mod my_contract { /* ... */ }