Skip to main content
11 votes
Accepted

Difference between __init and __init_unchained

From OpenZeppelin's docs, there is the following section: Initializer functions are not linearized by the compiler like constructors. Because of this, each __{ContractName}_init function embeds the ...
Ahmed Ihsan Tawfeeq's user avatar
6 votes
Accepted

How many storage gaps to add at the end of Base Upgradeable Contracts?

There is no optimal number as the use of storage gaps is just a convention. I would suggest you use 50 as in the majority of the examples, but this is really up to you.
Falcon Stakepool's user avatar
5 votes

"onlyOwner" Function restrict the call from child contract

Sammu Sundar. It happens because your Logic contract is not an owner/creator of the Storage contract (from what I understood). In this case, it would be better to introduce an additional access ...
Oleg Kondrakhanov's user avatar
5 votes
Accepted

couldnt understand implementaion of UpgradeabilityProxyFactory

The simplest way to initialize your contract is to use the interactive commands when creating the contract using openzeppelin create. You will be asked ? Do you want to call a function on the ...
abcoathup's user avatar
  • 1,348
4 votes
Accepted

Does function order also matter when writing upgradeable smart contracts?

TLDR: Only affects variables ZeppelinOS does upgradability by using the proxy pattern, you can actually change the way it behaves, depending on the specific implementation the order of variables may ...
Enrique Alcazar's user avatar
4 votes
Accepted

_disableInitializers() vs initializer vs reinitializer(uint8 version) in Openzeppelin/contracts-upgradeable?

So I searched about it and tried these out. And it basically is something like reinitializer(1) = initializer. You need to use reinitializer() in subsequent upgrades. _disableInitializer() just max ...
Abhik Banerjee's user avatar
4 votes
Accepted

upgradeble openzeppelin contracts - why the __gap is needed if you can add variables to the end?

__gap is used in base contracts to avoid storage clashes while using inheritance. You cannot add new variables to base contracts if the child has any variables of its own. Given the following ...
Ruwaifa Tahir's user avatar
4 votes
Accepted

Do people have a strong preference for implementing EIP-2535 or OpenZeppelin's Proxy Upgrade Pattern?

I'm currently building out a suite of contracts using the EIP-2535 standard. After doing extensive reading on both, for my needs EIP-2535 is superior. Code organization is much cleaner - You are able ...
saltorious's user avatar
4 votes

OpenZippelin upgradeability pattern | How can both implementation and proxy contracts share the same storage tho they were implemented independently?

good question, yes you are right the proxy contract and the implementation are deployed independently and have different storage layouts. The magic here is, that when calling the Proxy contract, ...
donoso.eth's user avatar
  • 1,503
4 votes
Accepted

OZ transparent upgradeable proxy admin reverts when trying upgrade an implementation

OpenZeppelin v5 TransparentUpgradeableProxy creates(deploys) its own ProxyAdmin contract. Now, in the proxy constructor you should provide not the ProxyAdmin contract address, but let's say the Admin'...
tenbits's user avatar
  • 2,458
3 votes
Accepted

How to make Solidity Contracts Upgradable with a mapping and state variables?

First the short answers: As we know the mappings can grow, how to allot a slot for them, and what would be the setters and getters look like? You could define a hash function that uses both a "...
Rob Hitchens's user avatar
  • 55.4k
3 votes
Accepted

How do Proxy Upgraded Logic Contracts Share Data

It might be cognitively useful to think of the proxy contract importing bytecode from the logic contracts for its own use because they execute in the context of the proxy and use the proxy for storage....
Rob Hitchens's user avatar
  • 55.4k
3 votes

How do Proxy Upgraded Logic Contracts Share Data

Upgradability in smart contracts is nice feature that gives you the option to upgrade your logic and keep the contract data safe. Let's take for example we have 2 contracts first one is where the data ...
Miroslav Nedelchev's user avatar
3 votes

Solidity 0.6.0 and address(f) to f.address

This change is about external function types. As you can read in the Breaking Changes: Conversions from external function types to address are now disallowed. Instead external function types have ...
alberto's user avatar
  • 3,343
3 votes
Accepted

Why would an upgradeable smart contract or bridge not be preferred?

An upgradeable contract is a contract for which the logic can be changed while keeping the same storage (data). For example you can add new functionality to an upgradeable contract without losing any ...
Lauri Peltonen's user avatar
3 votes
Accepted

Ethernaut Level 24 - Puzzle Wallet

Contract inheritance: UpgradeableProxy is just a template with some functions, constants and variables so PuzzleProxy can reuse. Yes you can reuse the logic written in parent contracts, some functions ...
minhhn2910's user avatar
  • 1,790
2 votes
Accepted

ZepplinOS: Where to set owner of the contract?

I think it'd better to explicit the owner via input param like below, instead of using msg.sender since msg.sender might be not what we intend to set because zos use contract proxy to make it ...
Tony Dang's user avatar
  • 2,151
2 votes
Accepted

Am I locked to one solc version for upgradeable smart contracts?

From Solidity the documentation: The layout of state variables in storage is considered to be part of the external interface of Solidity due to the fact that storage pointers can be passed to ...
Ismael's user avatar
  • 30.4k
2 votes
Accepted

A proxy for an upgradeable contract returns a wrong value

You have probably guessed you have a fundamental issue with the storage. I will try to explain. The whole idea of a "proxy" is that the proxy is running, so everything that happens unfolds ...
Rob Hitchens's user avatar
  • 55.4k
2 votes

Upgradability of smart contract

As a matter of fact, there are various architectural patterns to solve this problem. Yes, smart contracts are immutable. But the trick is that you can use multiple smart contracts together to create ...
Lauri Peltonen's user avatar
2 votes

Need help reducing contract size for ERC721Upgradeable Proxy Contract

Move all your image processing functions to a library and deploy separately. They do not require access to storage and it is very clean to keep that code separate. There's also other fancy ways to get ...
William Entriken's user avatar
2 votes
Accepted

Does it make sense to use OpenZepplin's upgradeable contract

It really depends of your use case and your users expectations. An upgradable contract means that there is an owner that can change the functions of the contract. If your users expect that your ...
Undead8's user avatar
  • 3,610
2 votes

TypeError: Member "current" not found or not visible after argument-dependent lookup in struct CountersUpgradeable.Counter storage ref

The problem is that using XX for YY isn't inherited. If you want to keep the nice interface for _tokenIds you have to do something like this: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; ...
Ismael's user avatar
  • 30.4k
2 votes
Accepted

Does a smart contract at V2 or V3 indicate that it is an upgradeable contract?

That's just naming. You can't figure out upgradeability just by looking at the name. In the case of Uniswap, they don't use upgradeability at all. They simply deploy new versions and modify their ...
Lauri Peltonen's user avatar
2 votes

Do people have a strong preference for implementing EIP-2535 or OpenZeppelin's Proxy Upgrade Pattern?

Sometimes you need it, sometimes you don't. Even in the same project. Keep in mind that the diamond, while sporting quite a list of excellent features, does bring with it some complexity. As devs, we ...
Cliff Hall's user avatar
2 votes
Accepted

Can you inherit contracts on upgradable contract for the next version of deployment?

It is possible, but normally it won't work as you change the storage layout. The ERC721Upgradeable has some state (token symbol, name, owners, etc..). When you inherit a contract, the state variables ...
donoso.eth's user avatar
  • 1,503
2 votes

onlyInitializing vs initializer in OpenZeppelin Upgradeable Contracts

All of your points are correct. The main problem stems from the fact that constructors can't be used. That's upgradeable contracts have to use regular functions to initialize them. But this should ...
Lauri Peltonen's user avatar
2 votes

Is it possible to change a constant variable value when using upgradeable pattern and deploying a new version?

Yes, you can override the constant, as the value doesn't occupy any storage slot, but exists in the runtime bytecode, which is deployed in the new contract.
tenbits's user avatar
  • 2,458
1 vote

_disableInitializers() vs initializer vs reinitializer(uint8 version) in Openzeppelin/contracts-upgradeable?

_disableInitializers() is called inside the constructor. This is done so that in the context of the logic contract the initializer is locked. Therefore any attacker will not able to call the ...
Tanishk Goyal's user avatar
1 vote
Accepted

Upgrade Solidity contract

If the storage gets messed up because of updating to a contract that has different positioning of old variables, you can easily update your contract again to old version, and no data will be lost.
zOthix's user avatar
  • 121

Only top scored, non community-wiki answers of a minimum length are eligible