ink_env::reflect

Trait ContractName

pub trait ContractName {
    const NAME: &'static str;
}
Expand description

Stores the name of the ink! smart contract.

§Note

The name is the identifier of the #[ink(storage)] annotated struct.

§Usage

#[ink::contract]
pub mod contract {
    #[ink(storage)]
    pub struct Contract {}

    impl Contract {
        #[ink(constructor)]
        pub fn constructor() -> Self {
            Self {}
        }

        #[ink(message)]
        pub fn message(&self) {}
    }
}

use contract::Contract;

assert_eq!(<Contract as ContractName>::NAME, "Contract",);

Required Associated Constants§

const NAME: &'static str

The name of the ink! smart contract.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§