Verified contractPartialGPL-3.0
Proxy
Address0x4e104a6b8a4411ebd19ae5d42900937696b50b5c
- Balance
0 ETH
- Transactions
50
- Compiler
solc 0.8.17
- Same code
100 more contracts
Details
- Compiler
- solc 0.8.17+commit.8df45f5f
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- london
- License
- GPL-3.0
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 17,848,814
- Creation transaction
- 0x75db349e60…c1f368055d
- Main copy (most transactions)
- 0x48e9fe52…1b7d9d6c
3 files
contracts/utils/Proxy.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
import "./LibRawResult.sol";
import "./Implementation.sol";
/// @notice Base class for all proxy contracts.
contract Proxy {
using LibRawResult for bytes;
/// @notice The address of the implementation contract used by this proxy.
Implementation public immutable IMPL;
// Made `payable` to allow initialized crowdfunds to receive ETH as an
// initial contribution.
constructor(Implementation impl, bytes memory initCallData) payable {
IMPL = impl;
(bool s, bytes memory r) = address(impl).delegatecall(initCallData);
if (!s) {
r.rawRevert();
}
}
// Forward all calls to the implementation.
fallback() external payable {
Implementation impl = IMPL;
assembly {
calldatacopy(0x00, 0x00, calldatasize())
let s := delegatecall(gas(), impl, 0x00, calldatasize(), 0x00, 0)
returndatacopy(0x00, 0x00, returndatasize())
if iszero(s) {
revert(0x00, returndatasize())
}
return(0x00, returndatasize())
}
}
}
contracts/utils/Implementation.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
// Base contract for all contracts intended to be delegatecalled into.
abstract contract Implementation {
error OnlyDelegateCallError();
error OnlyConstructorError();
address public immutable IMPL;
constructor() {
IMPL = address(this);
}
// Reverts if the current function context is not inside of a delegatecall.
modifier onlyDelegateCall() virtual {
if (address(this) == IMPL) {
revert OnlyDelegateCallError();
}
_;
}
// Reverts if the current function context is not inside of a constructor.
modifier onlyConstructor() {
if (address(this).code.length != 0) {
revert OnlyConstructorError();
}
_;
}
}
contracts/utils/LibRawResult.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
library LibRawResult {
// Revert with the data in `b`.
function rawRevert(bytes memory b) internal pure {
assembly {
revert(add(b, 32), mload(b))
}
}
// Return with the data in `b`.
function rawReturn(bytes memory b) internal pure {
assembly {
return(add(b, 32), mload(b))
}
}
}
Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "london",
"remappings": [
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/",
":openzeppelin/=lib/openzeppelin-contracts/",
":solmate/=lib/solmate/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.