Proxy Pattern
Securityपरिभाषा
Proxy pattern एक design pattern है जो smart contracts को upgradeable बनाता है। एक proxy contract user-facing address रहता है और सभी calls को implementation contract में delegatecall करता है। Implementation को change किया जा सकता है बिना proxy address change किए। यह complex pattern है और सावधानी से use करना चाहिए।
English version
Proxy pattern is a design pattern that makes smart contracts upgradeable. A proxy contract remains the user-facing address and delegatecalls all calls to the implementation contract. The implementation can be changed without changing the proxy address. This is a complex pattern that must be used carefully.
Code Example
contract Proxy {
address public implementation;
constructor(address _impl) {
implementation = _impl;
}
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 करें
Proxy Pattern को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें