Getting a "Caller is not the owner" on UpgradeableContracts with Account used for Deployment

According to the following comment found at this link, I should be able to call the “Withdraw” function and the “Pause” function of my contract (which uses the openzeppelin upgradeablecontracts modules) if I use the account that was used to deploy the contract.

The account that deploys the contract will be granted the minter and pauser
roles, as well as the default admin role, which will let it grant both minter
and pauser roles to other accounts.

However, if I call these functions using that same account, I am receiving the following error:

“revert Ownable: caller is not the owner”

In my migrations directory of my Smart Contract, I have the following files (using Truffle):

1_initial_migration.js
2_MyContract.js
3_deploy_MyContract.js

Am I not understanding something or am I missing something?

Thank you. J


:computer: Environment

How did you deploy the contract? The owner is set in the initialize function. If you’re using the OpenZeppelin Upgrades Plugins this is done automatically.

Thank you @frangio Yes, I was following the procedure on that page. However, since I was getting an error (Invalid number of parameters for "initialize") on the following line:

await deployProxy(MyContract, [42], { deployer });

I have used this one instead, found on another site.

await deployProxy(MyContract, [42], { deployer, initializer: false });

Perhaps this is where the problem comes from.

Thank you again. J

Yes indeed, you were disabling initialization and the owner was therefore not set.

Thank you again @frangio Got it to work by removing the [42] value. I wasn’t understanding what was this value.

J