# Can a Proxy written in Solidity 0.5 upgrade a Solidity 0.5 contract to a Solidity 0.6 contract?

**URL:** <https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394>\
**Category:** SDK\
**Created:** [February 25, 2020, 6:05pm UTC](https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394 "2020-02-25T18:05:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccolorado](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/ccolorado/32/670_2.png) [@ccolorado](https://forum.openzeppelin.com/u/ccolorado)\
**Post date:** [February 25, 2020, 6:05pm UTC](https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394/1 "2020-02-25T18:05:04Z")

</div>

Do you know if a Proxy written in solidity 5, can upgrade a solidity 5 contract into a contract written in solidity 6 and if so, would there be any tradeoffs?

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [February 28, 2020, 6:40am UTC](https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394/2 "2020-02-28T06:40:00Z")

</div>

Hi @ccolorado,

I’m not aware of any issues. We still need to ensure that we don’t change the order in which the contract state variables are declared, nor their type. (See [Modifying Your Contracts](https://docs.openzeppelin.com/upgrades/2.7/writing-upgradeable#modifying-your-contracts))

Any such upgrade would need appropriate testing.

---

<div class="post-metadata">

**Author:** ![frangio](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/frangio/32/15251_2.png) [@frangio](https://forum.openzeppelin.com/u/frangio)\
**Post date:** [February 28, 2020, 5:35pm UTC](https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394/3 "2020-02-28T17:35:42Z")

</div>

I don’t think there would be any issues either! And I agree that it would be necessary to thoroughly test it just because it’s something new. Please share your results if you do.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [March 2, 2020, 6:16am UTC](https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394/4 "2020-03-02T06:16:13Z")

</div>

Hi @ccolorado,

I tried a quick check, though any solution would need thorough testing.

## Box.sol

Solidity 0.5 from [Upgrading a Contract using the CLI](https://docs.openzeppelin.com/learn/upgrading-smart-contracts#upgrading-a-contract-via-cli)

```auto
// contracts/Box.sol
pragma solidity ^0.5.0;

contract Box {
    uint256 private value;

    // Emitted when the stored value changes
    event ValueChanged(uint256 newValue);

    // Stores a new value in the contract
    function store(uint256 newValue) public {
        value = newValue;
        emit ValueChanged(newValue);
    }

    // Reads the last stored value
    function retrieve() public view returns (uint256) {
        return value;
    }
}

```

Deploy using OpenZeppelin CLI 2.8 (otherwise use `oz create` for earlier versions)

```auto
$ npx oz deploy
✓ Compiled contracts with solc 0.5.16 (commit.9c3226ce)
? Choose the kind of deployment upgradeable
? Pick a network development
? Pick a contract to deploy Box
✓ Added contract Box
✓ Contract Box deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? No
✓ Setting everything up to create contract instances
✓ Instance created at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
0xCfEB869F69431e42cdB54A4F4f105C19C080A601

$ npx oz send-tx
? Pick a network development
? Pick an instance Box at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
? Select which function store(newValue: uint256)
? newValue: uint256: 42
✓ Transaction successful. Transaction hash: 0x9f007d7f0fcb278a979fafecfceb45a9190b707bb8a0c08a90ce33a16e5feaff
Events emitted:
 - ValueChanged(42)

```

## Box.sol (modified to Solidity 0.6)

```auto
// contracts/Box.sol
pragma solidity ^0.6.0;

contract Box {
    uint256 private value;

    // Emitted when the stored value changes
    event ValueChanged(uint256 newValue);

    // Stores a new value in the contract
    function store(uint256 newValue) public {
        value = newValue;
        emit ValueChanged(newValue);
    }

    // Reads the last stored value
    function retrieve() public view returns (uint256) {
        return value;
    }

    // Increments the stored value by 1
    function increment() public {
        value = value + 1;
        emit ValueChanged(value);
    }
}

```

Compile with solc 0.6, upgrade and interact

```auto
$ npx oz compile --solc-version 0.6.3
✓ Compiled contracts with solc 0.6.3 (commit.8dda9521)

$ npx oz upgrade
? Pick a network development
Nothing to compile, all contracts are up to date.
✓ Contract Box deployed
All implementations have been deployed
? Which instances would you like to upgrade? Choose by address
? Pick an instance to upgrade Box at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
? Call a function on the instance after upgrading it? No
✓ Instance upgraded at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601. Transaction receipt: 0xcd85e8481c8e15f37a2822e5ac829cec315484dc8cddde37625270358ff9370f
✓ Instance at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601 upgraded

$ npx oz send-tx
? Pick a network development
? Pick an instance Box at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
? Select which function increment()
✓ Transaction successful. Transaction hash: 0xb3eaceb24df52c4933d868113aabb02c12a91080e0c923373e1ddedae7b46325
Events emitted:
 - ValueChanged(43)

```

---

<div class="post-metadata">

**Author:** ![ccolorado](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/ccolorado/32/670_2.png) [@ccolorado](https://forum.openzeppelin.com/u/ccolorado)\
**Post date:** [March 3, 2020, 12:07am UTC](https://forum.openzeppelin.com/t/can-a-proxy-written-in-solidity-0-5-upgrade-a-solidity-0-5-contract-to-a-solidity-0-6-contract/2394/5 "2020-03-03T00:07:40Z")

</div>

Thank you, I am very grateful you put so much effort in this answer.
