Upgrade smart contracts 2: delegatecall

Delegatecall

delegatecall is a low level function similar to call.When contract A executes delegatecall to contract B, B's code is executed with contract A's storage, msg.sender and msg.value.

Common Call: When we call B's function from A, B's code is executed with contract B's storage. x in A is still 0.
Common Call: When we call B's function from A, B's code is executed with contract B's storage. x in A is still 0.
Delegatecall: When we call B's function from A, B's code is executed with contract A's storage. x in A will be 1.
Delegatecall: When we call B's function from A, B's code is executed with contract A's storage. x in A will be 1.

So we get a method to update the contract.

We can just change the address in A to call different contracts between B and B2 by using delegatecall.
We can just change the address in A to call different contracts between B and B2 by using delegatecall.

Example Code:

Subscribe to Hicss
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.