Owner not set when deploying minimal proxy from proxy factory

I created a proxy through deploy minimal function in proxy factory but the owner is coming to be address(0)

why is that i wanted to ask
This is my code in the target contract

event Initialized(address indexed thisAddress);

    function initialize(address _recipient, address _admin) public initializer {
    emit Initialized(address(this));
    address admin = _admin;
  Ownable(_recipient);
    }

deployment etc is done but the owner address in the deployed proxy comes out to be address(0)

what can be the reason for this?

1 Like

Hi @viraj124,

Welcome to the community forum :wave:
Thanks for posting here.

Your code is using Ownable with a constructor so I assume that you are using OpenZeppelin Contracts rather than OpenZeppelin Contracts Ethereum Package.

With minimal proxies (and upgradeable contracts) we can’t use constructors and need to use Initializers (see: Limitations of Contract Upgrades. This is what OpenZeppelin Contracts Ethereum Package is setup to do. (as per the forum post you found: Ownable contract owner is always the 0 address)

You should change to OpenZeppelin Contracts Ethereum Package for use with minimal proxies.

npm i @openzeppelin/contracts-ethereum-package

If you are using OpenZeppelin Contracts Ethereum Package v3, if your factory isn’t the owner then you could run into this issue: https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/issues/86 and may need to use Access Control instead for ownership.