i am making a upgradable contract, i am facing issue to set the proxy contract for implementation contract. I am usign openzeppelin-contracts-upgradable. This is my deployscript :

pragma solidity ^0.8.17;
import "forge-std/Script.sol";
import "../src/Proxy.sol";
import "../src/Game.sol";     // THIS IS LOGIC CONTRACT

contract ProxyScript is Script {
    function run() external {
        uint256 privateKey = vm.envUint("PRIVATE_KEY");
        Game game = new Game(); // Deploying the Game contract
       // May be i need to do something like this: Proxy proxy =new Proxy(address(game));
       // I know i have to deploy the proxy contract, but can't figure out how to fix it for 
       // logic contract so that proxy contract can delegate call to logic contract

This is my Proxy.sol:

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

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

contract Proxy is UUPSUpgradeable {
    constructor(address implementation) {
        // I set the constructor because i might need to deploy the proxy contract by 
        // passing the logic contract's address, like this: new Proxy(address(game))

    function _authorizeUpgrade(
        address newImplementation
    ) internal virtual override {}

How can i fix the logic contract in proxy contract so that proxy contract can delegatecall to logic contract's function???

1 Answer 1


Since you are inheriting from UUPSUpgradeable you will need to call it's constructor in your constructor since it requires arguments

constructor(address implementation) UUPSUpgradeable(implementation, "") {
  // your custom constructor code here

See this solidity documentation for more info: https://docs.soliditylang.org/en/v0.8.19/contracts.html#arguments-for-base-constructors

Then in your foundry script you can just deploy your Proxy as normal with something like:

Proxy p = new Proxy(address(game));

Note that if you want to have any kind of initialisation data you will need to update your constructor and pass it to the UUPSUpgradeable constructor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.