Skip to main content
Version: 3.x


Applicable to a method.

Flags a method (or multiple methods) for the ink! storage struct as constructor making it available to the API for instantiating the contract.

There must be at least one #[ink(constructor)] defined method.

Methods flagged with #[ink(constructor)] are special in that they are dispatchable upon contract instantiation. A contract may define multiple such constructors which allow users of the contract to instantiate a contract in multiple different ways.


use ink_lang as ink;

mod erc20 {
pub struct Erc20 { ... }

impl Erc20 {
pub fn new(initial_supply: Balance) -> Self { .. }

pub fn total_supply(&self) -> Balance { .. }

// etc.