Function std::auth::msg_sender
pub fn msg_sender() -> Result<Identity, AuthError> Expand description
Get the Identity (i.e. Address or ContractId) from which a call was made.
Returns a Ok(Identity), or Err(AuthError) if an identity cannot be determined.
Additional Information
Returns an AuthError::InputsNotAllOwnedBySameAddress if the caller is external and the inputs to the transaction are not all owned by the same address.
Should not return an AuthError::CallerIsInternal under any circumstances.
Returns
- [Result<Identity, AuthError>] -
Ok(Identity)if the identity can be determined,Err(AuthError)otherwise.
Examples
fn foo() {
match msg_sender() {
Ok(Identity::Address(address)) => log(address),
Ok(Identity::ContractId(contract_id)) => log(contract_id),
Err(AuthError::InputsNotAllOwnedBySameAddress) => log("Inputs not all owned by same address."),
Err(AuthError::CallerIsInternal) => log("Hell froze over."),
}
}