-
While browsing through the examples in the docs, this piece of code caught my attention: let sender: Result<Identity, AuthError> = msg_sender();
let sender = match sender.unwrap() {
Identity::Address(addr) => addr,
_ => revert(0),
}; Why is the For context, my background is in Solidity, and a little bit of Rust. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You can see here in the standard libarary where It can return |
Beta Was this translation helpful? Give feedback.
-
Exactly. The inputs need to belong to the same caller which could be an "address" or another "contract", hence the type |
Beta Was this translation helpful? Give feedback.
You can see here in the standard libarary where
msg_sender()
is implemented: https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/auth.sw#L34-L89It can return
AuthError::InputsNotAllOwnedBySameAddress
if the caller is external. I'm not an application dev so I can't elaborate more on the full semantics there, but it should make sense?