# Does reinitializer work during contract deployment?

**URL:** <https://forum.openzeppelin.com/t/does-reinitializer-work-during-contract-deployment/41794>\
**Category:** Upgrades\
**Created:** [October 9, 2024, 10:19am UTC](https://forum.openzeppelin.com/t/does-reinitializer-work-during-contract-deployment/41794 "2024-10-09T10:19:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoDzilla](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/dodzilla/32/11642_2.png) [@DoDzilla](https://forum.openzeppelin.com/u/DoDzilla)\
**Post date:** [October 9, 2024, 10:19am UTC](https://forum.openzeppelin.com/t/does-reinitializer-work-during-contract-deployment/41794/1 "2024-10-09T10:19:44Z")

</div>

I have deployed an upgradable ERC20 token first and verified it.

1. Token contract implementation: [https://amoy.polygonscan.com/address/0x172B508a2961CCb0F45F501E13410517a550676c](https://amoy.polygonscan.com/address/0x172B508a2961CCb0F45F501E13410517a550676c)
2. Proxy: [https://amoy.polygonscan.com/address/0x54D7E85668fdB05A2501edb1565fBbf5e2e8Bc07#code](https://amoy.polygonscan.com/address/0x54D7E85668fdB05A2501edb1565fBbf5e2e8Bc07#code)

Then I upgraded the contract with new logic contract (added mintable). That is here:

> **[tokenVersion2 | Address 0x4028b8D561793F0262A05b505b8252c65FE051C3 | PolygonScan](https://amoy.polygonscan.com/address/0x4028b8D561793F0262A05b505b8252c65FE051C3#code)**
>
> The Contract Address 0x4028b8D561793F0262A05b505b8252c65FE051C3 page allows users to view the source code, transactions, balances, and analytics for the contract address. Users can also interact and make transactions to the contract directly on...

I have a new `initialize` function with `reinitializer` modifier in the version 2 that I was expecting it work during the deployment but it didn't and I had to call it manually. Is this the expected behavior or did I do something wrong? My `initialize` function in the version 2 is this:

```auto
function initializeV2()
        external
        reinitializer(2)
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        _grantRole(MINTER_ROLE, msg.sender);
    }

```

---

<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:** [October 9, 2024, 3:25pm UTC](https://forum.openzeppelin.com/t/does-reinitializer-work-during-contract-deployment/41794/2 "2024-10-09T15:25:34Z")

</div>

If you are calling the ProxyAdmin contract directly to perform the upgrade, set the encoded function call for your `initializeV2` function in the `data` parameter. See [https://docs.openzeppelin.com/contracts/5.x/api/proxy#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-](https://docs.openzeppelin.com/contracts/5.x/api/proxy#ProxyAdmin-upgradeAndCall-contract-ITransparentUpgradeableProxy-address-bytes-)

If you are using Upgrades Plugins to perform the upgrade, use the [`call` option for Hardhat](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#upgrade-proxy) or the [`data` parameter for Foundry](https://docs.openzeppelin.com/upgrades-plugins/1.x/api-foundry-upgrades#Upgrades-Upgrades-upgradeProxy-address-string-bytes-).
