Attribute Macro sewup_derive::ewasm_main[][src]

#[ewasm_main]
Expand description

helps you setup the main function of a contract

There are three different kind contract output.

#[ewasm_main] The default contract output, the error will be return as a string message This is for a scenario that you just want to modify the data on chain only, and the error will to string than return.

#[ewasm_main(rusty)] The rust styl output, the result object from ewasm_main function will be returned, this is for a scenario that you are using a rust client to catch and want to catch the result from the contract.

#[ewasm_main(auto)] Auto unwrap the output of the result object from ewasm_main function. This is for a scenario that you are using a rust non-rust client, and you are only care the happy case of excuting the contract.

#[ewasm_main]
fn main() -> Result<()> {
    let contract = Contract::new()?;
    match contract.get_function_selector()? {
        ewasm_fn_sig!(check_input_object) => ewasm_input_from!(contract, check_input_object)?,
        _ => return Err(Error::UnknownHandle.into()),
    };
    Ok(())
}