# What is the correct way of checking Identity type and retrieving from storage?

**URL:** https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459
**Category:** Sway
**Tags:** faqs
**Created:** [December 19, 2024, 12:00pm UTC](https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459 "2024-12-19T12:00:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![eesheng](https://avatars.discourse-cdn.com/v4/letter/e/2bfe46/32.png) [@eesheng](https://forum.fuel.network/u/eesheng)
#### Post date: [December 19, 2024, 12:00pm UTC](https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459/1 "2024-12-19T12:00:06Z")

</div>

What is the correct standard way of checking Identity?

```sway
fn _check_manager() {
    let sender: Identity = msg_sender().unwrap();
    let owner: Identity = storage.owner.read(); 
    let manager: Identity = storage.manager.read();

    // Ensure the sender is either the owner or the manager
    require(sender == owner|| sender == manager, "Not authorized");
}

```

Another question is, If I initialized as Address, in other functions can I write with ContractID?

```sway
storage {
    owner: Identity = Identity::Address(Address::zero());,
    manager: Identity = Identity::Address(Address::zero()),
}

```

According to Docs, it can only be one. Was wondering if there would be any issue.

```auto
Enum std::identity::Identity
pub enum Identity {
    Address: Address,
    ContractId: ContractId,
}
The Identity type: either an Address or a ContractId.

```

---

<div class="post-metadata">

### Author: ![naz3eh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/naz3eh/32/2025_2.png) [@naz3eh](https://forum.fuel.network/u/naz3eh)
#### Post date: [December 19, 2024, 3:10pm UTC](https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459/2 "2024-12-19T15:10:58Z")

</div>

> [@eesheng](#):
>
> What is the correct standard way of checking Identity?
> 
> ```auto
> 
> ```

This is the correct implementation for checking if the sender is either the owner or the manager. You can have a look at [this example](https://github.com/FuelLabs/sway-examples/tree/src20-airdrop/airdrop/sway-programs/contract) for the ref.

> [@eesheng](#):
>
> Another question is, If I initialized as Address, in other functions can I write with ContractID?

Regarding the another question, yes, the `Identity` type can be either an `Address` or a `ContractId`, but not both at the same time. If you initialize a storage variable as an `Address` , you should consistently use it as an `Address` in other functions. Similarly, if you initialize it as a `ContractId` , you should use it as a `ContractId` . Mixing them can lead to errors because they are distinct types within the `Identity` enum.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)
#### Post date: [January 9, 2025, 11:12am UTC](https://forum.fuel.network/t/what-is-the-correct-way-of-checking-identity-type-and-retrieving-from-storage/7459/3 "2025-01-09T11:12:00Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
