1

I'm writing smart contract for Ethereum using Solidity and OpenZeppelin. I wish to implement this kind of situation

this kind of situation

Where I deploy a proxy for each user and the proxy uses the same smart contract with the storage of the proxy.

But I have not found the examples about it.

The unique example are this:

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
  const Box = await ethers.getContractFactory("BoxV1")
  console.log("Deploying Box, ProxyAdmin, and then Proxy...")
  // In order to use UUPS we have to manually specify so with the option kind: 'uups'.
  const proxy = await upgrades.deployProxy(Box, ['hash'], { initializer: 'initialize', kind: 'uups'})
  console.log("Proxy of Box deployed to:", proxy.address)
};

where I deploy the proxy with box. But I have not found the way to deploy the proxy alone and to link the proxy to the smart contract.

The goal is:

I have a smart contract that store a hash. I have 5.000.000 of user. I wish to give at each user the same smart contract. But one day I could update this smart contract, so I wish to do one or two transaction in order to update it. I thinks that I have to use the proxy but I have not found an example.

On above figure I have a user that has own proxy that is linked to another proxy. The idea is: one day I will update only the proxy with its smart contract.

Doe
  • 93
  • 5
  • It is not very clear from the description what you are trying to do, and what issues you are facing. Could you please explain what you imply by "But I have not found the way to deploy the proxy alone and to link the proxy to the smart contract." Please add some more code ( the solidity code of the Proxy contract that creates clones. ) – Shariq Hasan Khan Sep 26 '22 at 15:26
  • I have a smart contract that store a hash. I have 5.000.000 of user. I wish to give at each user the same smart contract. But one day I could update this smart contract, so I wish to do one or two transaction in order to update it. – Doe Sep 26 '22 at 15:38
  • I see you are already referring to the OpenZeppelin Upgradeable Contract. "I thinks that I have to use the proxy but I have not found an example." Do you mean "example" of web3/ether.js code or Solidity code? – Shariq Hasan Khan Sep 26 '22 at 15:55
  • Does this help? https://docs.openzeppelin.com/learn/upgrading-smart-contracts – Shariq Hasan Khan Sep 26 '22 at 15:56
  • I wish to have `user` -> `smart contract 1` -> `smart contract 2` -> `final smart contract` that I could update. I wish to link `smart contract 1` to `smart contract 2`. – Doe Sep 26 '22 at 19:03

1 Answers1

1

About link the proxy to the smart contract.

    import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";

You will be able to use upgradeTo function. Thus when you want to update your contract with some new functions or smth else, you can deploy your "BoxV2" contract and put it in updateTo.

  • And in which I can pass `proxy 1` to `proxy` in order that the user calls only `proxy1` and I can update only `proxy`? – Doe Sep 26 '22 at 18:29
  • But when I will have 5.000.000 users I have to deploy 5.000.000 of updating. I wish to avoid it. I wish to update only one smart contract – Doe Sep 26 '22 at 19:06
  • Maybe, have a look at Beacon Proxy Pattern. From the docs : "A different family of proxies are beacon proxies. This pattern, popularized by Dharma, allows multiple proxies to be upgraded to a different implementation in a single transaction." See this: https://docs.openzeppelin.com/contracts/4.x/api/proxy#UpgradeableBeacon – Shariq Hasan Khan Sep 27 '22 at 06:44