Skip to main content
Version: 5.x

no_main

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.

Example

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

Use instead:

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