Smart contract upgrade costs

Hi got a few questions regarding the upgradeability costs for a contract.

When using ZeppelinOS and updating the contract how are the costs to update the contract calculated?

Do they take the same costs as if the contract was deployed fresh from start or the cost will only be for the code changes in he functions/variables?

Does the storage affect the price, lets say I have 20 records already saved in a mapping would the cost to upgrade contract be the same as if there were no records ?

2 Likes

Hey @techbro965, that’s a good question! The cost of updating a contract does not depend on storage, but rather on two things:

1- Deploying the new logic contract (this is exactly the same as if the contract was deployed anew)
2- Updating your upgradeable instance from the old logic contract to the new one (constant cost, rather cheap, as it requires only to change the implementation slot in storage)

Note that, if you have multiple instances of the same contract, you need to pay the cost for (1) only once, and (2) for each instance. Even better, if you are upgrading an instance created directly from an EVM package, you don’t need to pay anything for (1), since it’s handled by the EVM package owner.

2 Likes