Struct ink_ir::Contract

source ·
pub struct Contract { /* private fields */ }
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.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.