# For OwnableUpgradeable is it mandatory to call \_\_Ownable\_init?

**URL:** <https://forum.openzeppelin.com/t/for-ownableupgradeable-is-it-mandatory-to-call-ownable-init/40360>\
**Category:** Upgrades\
**Created:** [April 25, 2024, 2:29am UTC](https://forum.openzeppelin.com/t/for-ownableupgradeable-is-it-mandatory-to-call-ownable-init/40360 "2024-04-25T02:29:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eeshenggoh](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@eeshenggoh](https://forum.openzeppelin.com/u/eeshenggoh)\
**Post date:** [April 25, 2024, 2:29am UTC](https://forum.openzeppelin.com/t/for-ownableupgradeable-is-it-mandatory-to-call-ownable-init/40360/1 "2024-04-25T02:29:11Z")

</div>

For OwnableUpgradeable is it mandatory to call \_\_Ownable\_init ? If I'm the deployer do I still need to initialize with \_\_Ownable\_init? Or can I completely ignore it?

#### 🔢 Code to reproduce

```auto
contract contractA is
    OwnableUpgradeable,
    PausableUpgradeable
{
       __Pausable_init();
       __Ownable_init(msg.sender); // Is this a must?
}

```

#### 💻 Environment

---

<div class="post-metadata">

**Author:** ![ericglau](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/ericglau/32/15149_2.png) [@ericglau](https://forum.openzeppelin.com/u/ericglau)\
**Post date:** [April 26, 2024, 7:07pm UTC](https://forum.openzeppelin.com/t/for-ownableupgradeable-is-it-mandatory-to-call-ownable-init/40360/2 "2024-04-26T19:07:37Z")

</div>

Yes, you should call `__Ownable_init` from your initializer function, and ensure your initializer function is called when deploying the proxy. Otherwise, the owner won't be set.

---

<div class="post-metadata">

**Author:** ![eeshenggoh](https://avatars.discourse-cdn.com/v4/letter/e/8dc957/32.png) [@eeshenggoh](https://forum.openzeppelin.com/u/eeshenggoh)\
**Post date:** [May 4, 2024, 10:22am UTC](https://forum.openzeppelin.com/t/for-ownableupgradeable-is-it-mandatory-to-call-ownable-init/40360/3 "2024-05-04T10:22:11Z")

</div>

> [@eeshenggoh](#):
>
> OwnableUpgradeable

According to `OwnableUpgradeable` contract:

```auto
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.

```

So why need to call the `__Ownable_init` function? Since you the deployer will be the owner of the deployed contract?

What happens if you did not call `__Ownable_init` function? Can I input `_transferOwnership(_factory);` in the initializer function and call it to transfer ownership??

---

<div class="post-metadata">

**Author:** ![ericglau](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/ericglau/32/15149_2.png) [@ericglau](https://forum.openzeppelin.com/u/ericglau)\
**Post date:** [May 6, 2024, 2:24pm UTC](https://forum.openzeppelin.com/t/for-ownableupgradeable-is-it-mandatory-to-call-ownable-init/40360/4 "2024-05-06T14:24:29Z")

</div>

@eeshenggoh What you described is from OpenZeppelin Contracts 4.x, where the owner is set to msg.sender in the initializer. See [https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v4.9.6/contracts/access/OwnableUpgradeable.sol#L29](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v4.9.6/contracts/access/OwnableUpgradeable.sol#L29). Whereas in version 5.x, you need to pass in the `initialOwner` parameter.

But either way, the recommendation is to call the `__Ownable_init` function, otherwise the storage is not set.

> Can I input `_transferOwnership(_factory);` in the initializer function and call it to transfer ownership??

Yes, you can see in the above OwnableUpgradeable code that it just calls `_transferOwnership`, so you could do that in your initializer if needed.
