19 votes
Accepted

What exactly is a proxy contract and why is there a security vulnerability involved in it?

A proxy contract is a contract which delegates calls to another contract. To interact with the actual contract you have to go through the proxy, and the proxy knows which contract to delegate the call ...
Lauri Peltonen's user avatar
16 votes
Accepted

How do I get the implementation contract address from the proxy contract address?

Most proxy contracts typically have a public variable defined as a: address public implementation; Which defines the address of the implementation contract. You could then call it as a view function ...
Patrick Collins's user avatar
11 votes

forward revert message from low level solidity call

The following code performs a delegate call, and if the delegate call reverts, the transaction is reverted with the reason given by the delegate call. (bool success, bytes memory result) = address(...
Thykof's user avatar
  • 211
10 votes

forward revert message from low level solidity call

It is simpler than you think: require(success, string (returndata)); See documentation for details. You may also forward raw bytes, but you will need to use assembly.
Mikhail Vladimirov's user avatar
10 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
9 votes
Accepted

What is the value of "address(this)" when delegate calling?

Remember how DELEGATECALL works: DELEGATECALL basically says that I'm a contract and I'm allowing (delegating) you to do whatever you want to my storage. DELEGATECALL is a security risk for the ...
Paul Razvan Berg's user avatar
9 votes
Accepted

How can I use a proxy contract with ethers.js?

I used attach to call the implementation functions from my proxy contract: adder = Delegate.attach(proxy.address) as Delegate
emag3m's user avatar
  • 106
8 votes
Accepted

Finding the address of the proxied to address of a proxy

Implementation is stored as value in IMPLEMENTATION_SLOT (see the source code), so you can get the underlined Contract with: let proxyContract = "0x4fabb145d64652a948d72533023f6e7a623c7c53"; ...
tenbits's user avatar
  • 1,979
6 votes

What exactly is a proxy contract and why is there a security vulnerability involved in it?

Proxies (or "diamonds", which is just a name for a specific proxy system specified as an EIP) allow part or all of a contract to be swapped out at any time, without changing the address of ...
Luke Hutchison's user avatar
5 votes

What's the difference between Truffle Migrations and ZeppelinOS upgradeable contracts?

Smart contracts are immutable (code cannot be changed) by design. Truffle and ZeppelinOS are platforms for the development of smart contracts for Ethereum based blockchains. Truffle migrate manages ...
abcoathup's user avatar
  • 1,338
5 votes
Accepted

hardhat-deploy deterministic deployment

In order to use Create2 and get the same address, you have to pass the same variables: create2(someValueToPreventCollisionWithCreate, msg.sender, salt, contractBytecode) So if your contractBytecode ...
Patrick Collins's user avatar
5 votes

Why is Bitwise AND operator used for comparing singleton address and 0xfff... in GnosisSafeProxy.sol

General objective of doing this and operation is to get extract the 20 bytes address with in a 32 bytes slot. There can be packed values with the address to clean up this is needed. The following ...
Tashun Sandaru's user avatar
4 votes
Accepted

What's the difference between Truffle Migrations and ZeppelinOS upgradeable contracts?

In case of truffle the stored values will not remain in the upgraded contract whereas in proxy approach it is possible to obtain the stored values in the upgraded contract too. In truffle upgrade a ...
Veerabala J's user avatar
4 votes
Accepted

Ownable in upgradeable contracts

You simply need to call the init method of OpenZeppelinUpgradesOwnable, which is __Ownable_init(), inside your initialize(...) method body. Also, remember to use the initializer to so as to restrict ...
Ahmed Ihsan Tawfeeq'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,383
3 votes
Accepted

forward revert message from low level solidity call

You can do it very concisely: (bool success, bytes memory result) = addr.delegatecall(data); if (success == false) { assembly { revert(add(result,32),mload(result)) } }
Adrien Husson's user avatar
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
  • 54.7k
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

Using a high level delegate call in upgradable contracts since Byzantium

One issue is that you copy your data into memory starting at address 0. This will work for return sizes less than 64 bytes, but will start overwriting other memory at that point. Instead you should ...
Tjaden Hess's user avatar
  • 36.7k
3 votes
Accepted

On the unstructured storage upgrade pattern, why do we have to follow the structure of the previous contract?

This is because Solidity sets up the variables in storage sequentially. So if you move the references of storage variables in the upgraded one, they'll be referring to the wrong slot in storage. Here'...
natewelch_'s user avatar
  • 11.9k
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
  • 54.7k
3 votes
Accepted

Call fallback function from eth-brownie from proxy

You need to use The actual ABI of the implementation instead of the ABI file of the proxy contract Address of the proxy contract from brownie import Box, TransparentUpgradeableProxy, Contract ...
Mikko Ohtamaa's user avatar
3 votes
Accepted

EIP-2535 Diamond implementation how-to?

Answering myself: Diamond proxy MUST NOT implement the interfaces. Client code using contract-like code-style to build the transaction (vs building them manually) need to instantiate the contract-...
earizon's user avatar
  • 596
3 votes

Ethernauts level 25 solution help

Your issues are here : (bool success, bytes memory data) = address(originalContract).call{gas:7000}(abi.encodeWithSignature("initialize()")); And here : (bool success, bytes memory data) = ...
hroussille's user avatar
  • 7,386
3 votes

How can I decode the event log I receive in my txn where there more than 1 smart contract involved and the emitted event cannot be found in ABI

The ABI posted to Mumbai implementation contract is probably lacking. Take transaction 0x32e3230a7478315092a04ef57fc2426947ec5031c6977c7b184e7bcd02be9216 for instance, if you look at Mumbai Explorer ...
Kof's user avatar
  • 2,934
3 votes
Accepted

Chainlink Oracle - What events are emitted and which should i listen to for price updates?

The address that you mentioned is actually the Price Feed and not the Aggregator contract itself. The Price Feed acts as a "Proxy" contract that reads the submitted price data on the current ...
Christian Dahdah's user avatar
3 votes

How can I create a Factory of TransparentUpgradeableProxy?

The second parameter of TransparentUpgradeableProxy sets the proxy admin address. When initializing proxy in the first line of the constructor of SmartWalletProxy.sol, you're specifying the zero ...
vlj614's user avatar
  • 376
3 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
  • 1,979
2 votes
Accepted

What happens with the balance of a contract after it is upgraded using ZeppelinOS?

ZeppelinOS' unstructured storage, like most proxy patterns, works by presenting a front-end contract (the proxy) with its logic delegated to an implementation contract. This way, the balance (eth) ...
martriay's user avatar
  • 427
2 votes
Accepted

Upgradable contract proxy pattern: Get the invoked method name in the fallback function

Full name of the function being called is not passed to the smart contract, but only the first 4 bytes of the hash of function signature. These 4 bytes you can obtain as msg.sig. See documentation ...
Mikhail Vladimirov's user avatar

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