delegatecall

delegatecall is a low-level EVM instruction that calls contract functions from the context of the contract that makes the call.

Functions that are executed through a delegatecall borrow all state context from the calling contract including smart contract storage, msg.sender and other contract-scoped values.

The behaviour is akin to the delegated function being borrowed by the initial contract.

delegatecall is used widely throughout the Extendable pattern and is the main feature that facilitates the modularity of this design pattern. It allows us to be able to deploy separate Extensions that are standalone contracts and make them usable by other contracts whilst still maintaining the correct data access.

Extensions define some functions that can be commonly used. Extendable performs delegatecalls to Extensions, making calls to the functions but utilising the contract state of Extendable.

Last updated