Description:
Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"proxy.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.20;\r
\r
/* -------------------------------------------------------------------------- */\r
/* Minimal ERC1967 Proxy (for UUPS) */\r
/* -------------------------------------------------------------------------- */\r
contract ClaimsProxy {\r
bytes32 private constant IMPLEMENTATION_SLOT =\r
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\r
\r
constructor(address _logic, bytes memory _data) {\r
_setImplementation(_logic);\r
if (_data.length > 0) {\r
(bool ok, ) = _logic.delegatecall(_data);\r
require(ok, "init failed");\r
}\r
}\r
\r
function _implementation() internal view returns (address impl) {\r
bytes32 slot = IMPLEMENTATION_SLOT;\r
assembly {\r
impl := sload(slot)\r
}\r
}\r
\r
function _setImplementation(address newImpl) private {\r
require(newImpl != address(0), "bad impl");\r
bytes32 slot = IMPLEMENTATION_SLOT;\r
assembly {\r
sstore(slot, newImpl)\r
}\r
}\r
\r
fallback() external payable {\r
_delegate(_implementation());\r
}\r
\r
receive() external payable {\r
_delegate(_implementation());\r
}\r
\r
function _delegate(address impl) internal {\r
assembly {\r
calldatacopy(0, 0, calldatasize())\r
let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)\r
returndatacopy(0, 0, returndatasize())\r
switch result\r
case 0 {\r
revert(0, returndatasize())\r
}\r
default {\r
return(0, returndatasize())\r
}\r
}\r
}\r
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-10-30 12:51:15
Comments
Log in to comment.
No comments yet.