Trait ink_env::ContractReference

source ·
pub trait ContractReference {
    type Type;
}
Expand description

Refers to the generated ink! smart contract reference type.

§Note

Given an ink! storage struct with identifier Contract the ink! codegen produces the ink! root type Contract and the ink! reference type ContractRef.

This trait exists so that users can avoid using a generated identifier to refer to the generated reference type of the ink! smart contract.

§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,
    ContractRef,
};

// The following line only compiles successfully if both
// `ContractReference` and `<Contract as ContractReference>::Type`
// are of the same type.
const _: IsSameType<<Contract as ContractReference>::Type> =
    <IsSameType<ContractRef>>::new();

Required Associated Types§

source

type Type

The generated contract reference type.

Implementors§