Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

armanriazi•substrate•call•dispatchable•func#ensure_signed#frame_system

///ensure_signed
///ensure that the caller of the function was a regular user who owns a private key. This function also returns who that caller was. We store the caller's identity in the caller variable.
/// Ensure that the caller is a regular keypair account

pub fn say_hello(origin) -> DispatchResult {
    // Ensure that the caller is a regular keypair account
    let caller = ensure_signed(origin)?;

    // Print a message
    print("Hello World");
    // Inspecting variables
    debug::info!("Request sent by: {:?}", caller);

    // Indicate that this call succeeded
    Ok(())
}
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
7+2 =