You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add a @delegate decorator which automatically moves code into external contracts
Motivation
because of the EIP-170 codesize limit, developers often end up splitting logical contracts into multiple physical contracts, delegatecalling into them as necessary. we could abstract this away by providing a @delegate decorator, which specifies for the given function to be inserted into an external contract, and then delegatecalling into the external contract.
Specification
add a @delegate decorator, which is only valid on @external functions. during contract initialization, the auxiliary contract is also created and saved in the main contract's bytecode. in the selector table, if the function is called, the calldata is forwarded to the auxiliary contract using delegatecall.
depending on how many delegate'd functions there are, multiple external contracts can be created, thus not requiring any given logical contract to be required to be split over multiple files.
Simple Summary
add a
@delegate
decorator which automatically moves code into external contractsMotivation
because of the EIP-170 codesize limit, developers often end up splitting logical contracts into multiple physical contracts,
delegatecall
ing into them as necessary. we could abstract this away by providing a@delegate
decorator, which specifies for the given function to be inserted into an external contract, and thendelegatecall
ing into the external contract.Specification
add a
@delegate
decorator, which is only valid on@external
functions. during contract initialization, the auxiliary contract is also created and saved in the main contract's bytecode. in the selector table, if the function is called, the calldata is forwarded to the auxiliary contract usingdelegatecall
.depending on how many delegate'd functions there are, multiple external contracts can be created, thus not requiring any given logical contract to be required to be split over multiple files.
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: