Napping Peanut Monsters


    1.1.3 • Public • Published

    Upgradeable Proxy Plus

    Based on upgradeable-proxy. More info here.


    • Implements both upgradeable-proxy features at same time:
      • Upgrade safety and protection
        • Experimental safety features* were implemented to the upgradeable pattern to protect the contract from being accidentally or maliciousl upgraded to the wrong contract. A target contract for the SafeProxy must satisfy, at a minimum, the following conditions to be able to call Proxy.upgradeTo() to change the target:
          1. Must have a address target variable
          2. Must have a upgradeTo(address) public function
          3. Must have a transferOwnership(address) public function
      • Permissioned (Ownable) proxy upgrade
        • Ownable to allow the administrator of the proxy to be set as a multisig or DAO-like contract to provide distributed governance.
    • Inherits from upgradeable-proxy
      • 100% Upgradeable strategy
      • Comprehensive test suite


    • empty functions that do nothing will satisfy these conditions.
    • one of the safety features depends on the use of the EXTCODESIZE opcode which may not work after the Serenity hard fork.
    • carefully consider if these safety features are necessary, onced deployed they cannot be changed.


    npm install upgradeable-proxy-plus


    Deploy Upgradeable CheckContract

    Deploy Upgradeable CheckContract so that after Serenity hardfork, the method to check if an address is a contract can be upgraded. More information here

    let checkContractInstance = await deployer.deploy(CheckContract);

    Deploy CheckContract's Proxy.

    Deploy a Proxy for the just deployed CheckContract.

    let proxyInstance = await deployer.deploy(

    Get CheckContract's instance by proxy

    Get the instance of the CheckContract by proxy, and initialize.

    let checkContractInstanceByProxy =;
    await checkContractInstanceByProxy.initialize();

    Make some tests

    (OPTIONAL) Make some tests to make sure the method isContract called by proxy is properly working.

    let testOne = await
    assert.equal(testOne, true);
    let testTwo = await
    assert.equal(testTwo, false);

    Deploy the UpgradeablePlus contract

    let addressSimpleV1 = await deployer.deploy(AddressSimpleV1);

    Deploy AddressSimpleV1's ProxyPlus

    Deploy a ProxyPlus for the just deployed AddressSimpleV1Safe.

    let proxyPlus = await

    Get AddressSimpleV1's instance by proxy

    Get the instance of the AddressSimpleV1Safe by proxy, and initialize.

    let addressSimpleV1byProxy =;
    await addressSimpleV1byProxy.initialize();

    Make some tests

    (OPTIONAL) Make some tests to make sure the UpgradeablePlus contract called by proxy is properly working.

    const inputValue = "0xa4532e9f6f9c4e4abb89bdbb73d3003210ede61c",
      inputValue2 = "0x5c28D962c93282C6Fbe820f9AB33844D96b4853e";
    await addressSimpleV1byProxy.setValue(inputValue);
    let value = await;
    assert.equal(value, inputValue, "Not equal to inputValue");
    let addressSimpleV2 = await deployer.deploy(AddressSimpleV2);
    await addressSimpleV1byProxy.upgradeTo(addressSimpleV2.address);
    await addressSimpleV1byProxy.initialize();
    value = await;
    assert.equal(value, inputValue, "Not equal to inputValue");
    await addressSimpleV1byProxy.setValue(inputValue2);
    value = await;
      "Not equal to constant defined in function"

    The full example was written inside migrations and is fully functional here.

    How to import these library contracts?

    Use the following strategy to import library contracts to your own contracts

    import "upgradeable-proxy-plus/contracts/UpgradeablePlus.sol";


    npm i upgradeable-proxy-plus

    DownloadsWeekly Downloads






    Unpacked Size

    14.7 kB

    Total Files


    Last publish


    • prophetdaniel