WAGMI, Keep Buidling! ๐ ๏ธ
The important thing to note when using .delegatecall() is that the context the original contract is passed to the target, and all state changes in the target contract reflect on the original contract's state and not on the target contract's state even though the function is being executed on the target contract.
- Proxy Contracts
- Upgrade Contracts (the logic can change, but the data is never fragmented.)
But, since .delegatecall() modifies the storage of the contract calling the function, there are some nasty attacks that can be designed if .delegatecall() is not properly implemented. We will now simulate an attack using .delegatecall().
Use stateless library contracts which means that the contracts to which you deletegate the call should only be used for execution of logic and should not maintain state.