Function ink_env::decode_input

source ·
pub fn decode_input<T>() -> Result<T>
where T: Decode,
Expand description

Returns the execution input to the executed contract and decodes it as T.

§Note

  • The input is the 4-bytes selector followed by the arguments of the called function in their SCALE encoded representation.
  • No prior interaction with the environment must take place before calling this procedure.

§Usage

Normally contracts define their own enum dispatch types respective to their exported constructors and messages that implement scale::Decode according to the constructors or messages selectors and their arguments. These enum dispatch types are then given to this procedure as the T.

When using ink! users do not have to construct those enum dispatch types themselves as they are normally generated by the ink! code generation automatically.

§Errors

If the given T cannot be properly decoded from the expected input.