Delegatecall
Securityपरिभाषा
Delegatecall एक low-level operation है जो दूसरे contract के code को current contract के context में execute करता है। इसका मतलब है कि msg.sender, msg.value और storage वही रहते हैं। यह proxy patterns और upgradeable contracts में use होता है, लेकिन सावधानी से use करना चाहिए क्योंकि storage collisions हो सकते हैं।
English version
Delegatecall is a low-level operation that executes another contract's code in the current contract's context. This means msg.sender, msg.value and storage remain the same. It is used in proxy patterns and upgradeable contracts, but must be used carefully to avoid storage collisions.
Code Example
// Pattern Proxy avec delegatecall
contract Proxy {
address public implementation;
fallback() external payable {
address impl = implementation;
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
}संबंधित शब्द
संबंधित पेज
Solingo पर इस concept को practice करें
Delegatecall को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें