Simpler `delegatecall` and `staticcall` using `call` options

The current pattern to explicitly perform either a delegatecall or staticcall often requires adding a lot of boilerplate using abi.encodeWithSelector() followed by target.staticcall(data) and return data decoding.

A far more user friendly approach would be to repurpose the call properties syntax and allow the compiler to generate the underlying code.

As an example:

(uint a, uint b) = IContract(addr).myFunction{static: true}();

Similarly for delegatecall:

(uint a, uint b) = IContract(addr).myDelegateFunction{delegate: true}();

Real world examples of code that could be far more simple if this feature was to be implemented:

Couldn’t find any issues or topics that recommend the same syntax before.


See also First class language support for proxies and delegatecall - #2 by aathan

1 Like