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 into ir::Config.
  • The ink_module token stream must properly decode into ir::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 specify Environment different from the default environment types.
  • storage-alloc: If true enables the dynamic storage allocator facilities and code generation of the ink! smart contract. Does incur some overhead. The default is true.
  • as-dependency: If true 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 is false.

Note that we might add more configuration fields in the future if necessary.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.