Struct ink_lang_ir::Contract [−][src]
pub struct Contract { /* fields omitted */ }
Expand description
An ink! contract definition consisting of the ink! configuration and module.
This is the root of any ink! smart contract definition. It contains every information accessible to the ink! smart contract macros. It is also used as the root source for the ink! code generation.
Example
#[ink::contract(/* optional ink! configurations */)]
mod my_contract {
/* ink! and Rust definitions */
}
Implementations
Creates a new ink! contract from the given ink! configuration and module token streams.
The ink! macro should use this constructor in order to setup ink!.
Note
- The
ink_config
token stream must properly decode intoir::Config
. - The
ink_module
token stream must properly decode intoir::ItemMod
.
Errors
Returns an error if the provided token stream cannot be decoded properly into a valid ink! configuration or ink! module respectively.
Returns the ink! inline module definition.
Note
The ink! inline module definition is the module that comprises the whole ink! smart contract, e.g.:
#[ink::contract]
mod my_contract {
// ... definitions
}
Returns the configuration of the ink! smart contract.
Note
The configuration is given via the #[ink::contract(config))]
attribute
macro annotation itself within the (config)
part. The available fields
are the following:
types
: To specifyEnvironment
different from the default environment types.storage-alloc
: Iftrue
enables the dynamic storage allocator facilities and code generation of the ink! smart contract. Does incur some overhead. The default istrue
.as-dependency
: Iftrue
compiles this ink! smart contract always as if it was a dependency of another smart contract. This configuration is mainly needed for testing and the default isfalse
.
Note that we might add more configuration fields in the future if necessary.