Upgradable ProxyFactory (No CLI)

:computer: Environment
I am using the Hardhat Upgrades Plugin (latest)

Hey all, I am getting a bit confused how i can achieve what i need for my project. I have an idea but im unsure if i have come up with the best way to implement. Could someone please point me to the bits of the documentation that will help me achieve what i need.

  • I will be designing a smart contract that allows 2 parties to digitally sign a “contract” stored off chain (this can be a pdf, json object, jpeg etc), along with a few other features. A new contract will be deployed each time consent is required (unlimited amounts of the same contracts possibly deployed)

My idea is that i can create an implementation contract, then use a factory to deploy a proxy contract every time consent is required.

The implementation contract should be upgradeable i.e. to fix bugs / add functionality and optionally i should be able totally replace the implementation with a new one.

As there will potentially be 1000’s of proxies deployed i need a way to update the implementation each proxy is pointing to encase of a bug. When the proxy implementation is updated each new proxy created uses the upgraded implementation.

Proxies will be deployed pragmatically from a server so id like to avoid using the HardHat CLI or Hardhat scripts to do deployments of proxy contracts

With my current limited knowlage about OpenZepplin (and hardhat, previously truffle user) I have come up with this implementation.

If i am missing something here and this implementation does not work how i think it will can someone point out the flaw.

if it is a viable solution to my problem can someone point me to parts of the docs that will help me achieve this

I have only got as far as this (I havent even looked into the Becon yet as i’m unsure how to implement the proxy factory)

Implementation contract

pragma solidity ^0.7.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"

* @title Logical contract for one-to-many concent
contract ConcentOneToMany is Initializable, Ownable {
string public name;

* @dev Logic contract that proxies point to
* @param _name name
* @param _owner The address of the ConcentOneToMany owner
function initialize(string memory _name, address _owner) public {
    name = _name;

Proxy factory

from reading the docs i figured proxy factory was best way to achieve this but i can see this is just part of the SDK

pragma solidity ^0.7.0;

import "./Thing.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"
// import '@openzeppelin/upgrades/contracts/upgradeability/ProxyFactory.sol';

contract FactoryConcentOneToMany is ProxyFactory {
  address public implementationContract;

  constructor (address _implementationContract) public {
    implementationContract = _implementationContract;

  function createProxy(bytes memory _data) public returns (address){
    address proxy = deployMinimal(implementationContract, _data);
    return proxy;

Thanks for your time and help, really appriceted

1 Like

Hi @Rick_Sanchez,

For your scenario you could look at the Beacon Proxy: https://docs.openzeppelin.com/contracts/4.x/api/proxy#beacon