# Deploying Upgradeable Proxies and Proxy Admin from Factory contract

**URL:** https://forum.openzeppelin.com/t/deploying-upgradeable-proxies-and-proxy-admin-from-factory-contract/12132
**Category:** Upgrades
**Created:** [July 8, 2021, 7:49pm UTC](https://forum.openzeppelin.com/t/deploying-upgradeable-proxies-and-proxy-admin-from-factory-contract/12132 "2021-07-08T19:49:58Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![julianmrodri](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@julianmrodri](https://forum.openzeppelin.com/u/julianmrodri)
#### Post date: [July 10, 2021, 6:00am UTC](https://forum.openzeppelin.com/t/deploying-upgradeable-proxies-and-proxy-admin-from-factory-contract/12132/3 "2021-07-10T06:00:40Z")

</div>

@frangio Here is my initial attempt. Please let me know if its in the right direction.

It looks too easy to be true. I created two contracts the `UpgradeableToken` and the `Factory` contract which deploys the Tokens. I realized I don’t need a `ProxyAdmin` for UUPS.

One of the doubts I had was which type of “Proxy” should I use for UUPS. I went for `ERC1967Proxy` not sure if it’s the correct choice.

**MyTokenUpgradeable**

```auto
// SPDX-License-Identifier: MIT

pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/token/ERC20/presets/ERC20PresetFixedSupplyUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";

contract MyTokenUpgradeable is
    ERC20PresetFixedSupplyUpgradeable,
    UUPSUpgradeable,
    OwnableUpgradeable
{
    function initialize(
        string memory name,
        string memory symbol,
        uint256 initialSupply,
        address owner
    ) public override initializer {
        __ERC20PresetFixedSupply_init(name, symbol, initialSupply, owner);
        __Ownable_init();
        transferOwnership(owner);
    }

    function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}

```

**MyTokenFactory**

```auto
// SPDX-License-Identifier: MIT

pragma solidity 0.8.4;

import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "./MyTokenUpgradeable.sol";

contract MyTokenFactoryUUPS {
    address immutable tokenImplementation;

    event TokenDeployed(address tokenAddress);

    constructor() {
        tokenImplementation = address(new MyTokenUpgradeable());
    }

    function createToken(string calldata name, string calldata symbol, uint256 initialSupply, address owner) external returns (address) {
        ERC1967Proxy proxy = new ERC1967Proxy(
            tokenImplementation,
            abi.encodeWithSelector(MyTokenUpgradeable(address(0)).initialize.selector, name, symbol, initialSupply, owner)
        );
        emit TokenDeployed(address(proxy));
        return address(proxy);
    }
}

```

One thing I wasn’t sure is if there is a better way to set the new owner for the Token, but seems like I have to do `__Ownable_init` so I can then transfer it to the provided _owner_. Any workaround to avoid the 2-step process?

Thank you very much for all your support!

Regards,  
Julian

---

_[View the full topic](https://forum.openzeppelin.com/t/deploying-upgradeable-proxies-and-proxy-admin-from-factory-contract/12132)._
