Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Read Proxy
Write Contract
Write Proxy
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- EIP1967Proxy
- Optimization enabled
- true
- Compiler version
- v0.8.15+commit.e14f2714
- Optimization runs
- 200
- EVM Version
- london
- Verified at
- 2024-10-28T16:26:10.648522Z
src/proxy/EIP1967Proxy.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.15;
import "./EIP1967Admin.sol";
/**
* @title EIP1967Proxy
* @dev Upgradeable proxy pattern implementation according to minimalistic EIP1967.
*/
contract EIP1967Proxy is EIP1967Admin {
// EIP 1967
// bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
uint256 internal constant EIP1967_IMPLEMENTATION_STORAGE =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
event Upgraded(address indexed implementation);
event AdminChanged(address previousAdmin, address newAdmin);
constructor(address _admin, address _implementation, bytes memory _data) payable {
_setAdmin(_admin);
_setImplementation(_implementation);
if (_data.length > 0) {
bool status;
assembly {
status := callcode(gas(), _implementation, callvalue(), add(_data, 32), mload(_data), 0, 0)
}
require(status, "EIP1967Proxy: initialize call failed");
}
}
/**
* @dev Tells the proxy admin account address.
* @return proxy admin address.
*/
function admin() public view returns (address) {
return _admin();
}
/**
* @dev Tells the proxy implementation contract address.
* @return res implementation address.
*/
function implementation() public view returns (address res) {
assembly {
res := sload(EIP1967_IMPLEMENTATION_STORAGE)
}
}
/**
* @dev Updates address of the proxy owner.
* Callable only by the proxy admin.
* @param _admin address of the new proxy admin.
*/
function setAdmin(address _admin) external onlyAdmin {
_setAdmin(_admin);
}
/**
* @dev Updates proxy implementation address.
* Callable only by the proxy admin.
* @param _implementation address of the new proxy implementation.
*/
function upgradeTo(address _implementation) external onlyAdmin {
_setImplementation(_implementation);
}
/**
* @dev Updates proxy implementation address and makes an initialization call to new implementation.
* Callable only by the proxy admin.
* @param _implementation address of the new proxy implementation.
* @param _data calldata to pass through the new implementation after the upgrade.
*/
function upgradeToAndCall(address _implementation, bytes calldata _data) external payable onlyAdmin {
_setImplementation(_implementation);
(bool status,) = address(this).call{value: msg.value}(_data);
require(status, "EIP1967Proxy: update call failed");
}
/**
* @dev Fallback function allowing to perform a delegatecall to the given implementation.
* This function will return whatever the implementation call returns
*/
fallback() external payable {
address impl = implementation();
require(impl != address(0));
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
/**
* @dev Internal function for transfer current admin rights to a different account.
* @param _admin address of the new administrator.
*/
function _setAdmin(address _admin) internal {
address previousAdmin = admin();
require(_admin != address(0));
require(previousAdmin != _admin);
assembly {
sstore(EIP1967_ADMIN_STORAGE, _admin)
}
emit AdminChanged(previousAdmin, _admin);
}
/**
* @dev Internal function for setting a new implementation address.
* @param _implementation address of the new implementation contract.
*/
function _setImplementation(address _implementation) internal {
require(_implementation != address(0));
require(implementation() != _implementation);
assembly {
sstore(EIP1967_IMPLEMENTATION_STORAGE, _implementation)
}
emit Upgraded(_implementation);
}
}
/
// SPDX-License-Identifier: CC0-1.0
pragma solidity 0.8.15;
/**
* @title EIP1967Admin
* @dev Upgradeable proxy pattern implementation according to minimalistic EIP1967.
*/
contract EIP1967Admin {
// EIP 1967
// bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
uint256 internal constant EIP1967_ADMIN_STORAGE = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
modifier onlyAdmin() {
require(msg.sender == _admin(), "EIP1967Admin: not an admin");
_;
}
function _admin() internal view returns (address res) {
assembly {
res := sload(EIP1967_ADMIN_STORAGE)
}
}
}
Compiler Settings
{"remappings":[":@gnosis/=lib/@gnosis/",":@gnosis/auction/=lib/@gnosis/auction/contracts/",":@openzeppelin/=lib/@openzeppelin/contracts/",":@openzeppelin/contracts/=lib/@openzeppelin/contracts/contracts/",":ds-test/=lib/forge-std/lib/ds-test/src/",":forge-std/=lib/forge-std/src/"],"optimizer":{"runs":200,"enabled":true},"metadata":{"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"london","compilationTarget":{"src/proxy/EIP1967Proxy.sol":"EIP1967Proxy"}}
Contract ABI
[{"type":"constructor","stateMutability":"payable","inputs":[{"type":"address","name":"_admin","internalType":"address"},{"type":"address","name":"_implementation","internalType":"address"},{"type":"bytes","name":"_data","internalType":"bytes"}]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"fallback","stateMutability":"payable"},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"admin","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"res","internalType":"address"}],"name":"implementation","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAdmin","inputs":[{"type":"address","name":"_admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"_implementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"_implementation","internalType":"address"},{"type":"bytes","name":"_data","internalType":"bytes"}]}]
Contract Creation Code
0x608060405260405161090538038061090583398101604081905261002291610227565b61002b836100b3565b61003482610149565b8051156100ab57600080600083516020850134875af29050806100a95760405162461bcd60e51b8152602060048201526024808201527f4549503139363750726f78793a20696e697469616c697a652063616c6c2066616044820152631a5b195960e21b606482015260840160405180910390fd5b505b50505061031a565b60006100bd6101d8565b90506001600160a01b0382166100d257600080fd5b816001600160a01b0316816001600160a01b0316036100f057600080fd5b6000805160206108c5833981519152829055604080516001600160a01b038084168252841660208201527f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a15050565b6001600160a01b03811661015c57600080fd5b6001600160a01b03811661017c6000805160206108e58339815191525490565b6001600160a01b03160361018f57600080fd5b6000805160206108e58339815191528190556040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60006101f06000805160206108c58339815191525490565b905090565b80516001600160a01b038116811461020c57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60008060006060848603121561023c57600080fd5b610245846101f5565b925060206102548186016101f5565b60408601519093506001600160401b038082111561027157600080fd5b818701915087601f83011261028557600080fd5b81518181111561029757610297610211565b604051601f8201601f19908116603f011681019083821181831017156102bf576102bf610211565b816040528281528a868487010111156102d757600080fd5b600093505b828410156102f957848401860151818501870152928501926102dc565b8284111561030a5760008684830101525b8096505050505050509250925092565b61059c806103296000396000f3fe60806040526004361061004a5760003560e01c80633659cfe61461009d5780634f1ef286146100bd5780635c60da1b146100d0578063704b6c021461010a578063f851a4401461012a575b60006100626000805160206105478339815191525490565b90506001600160a01b03811661007757600080fd5b3660008037600080366000845af43d6000803e808015610096573d6000f35b3d6000fd5b005b3480156100a957600080fd5b5061009b6100b836600461043a565b61013f565b61009b6100cb36600461045c565b610194565b3480156100dc57600080fd5b50600080516020610547833981519152545b6040516001600160a01b03909116815260200160405180910390f35b34801561011657600080fd5b5061009b61012536600461043a565b610293565b34801561013657600080fd5b506100ee6102dc565b600080516020610527833981519152546001600160a01b0316336001600160a01b0316146101885760405162461bcd60e51b815260040161017f906104df565b60405180910390fd5b610191816102f9565b50565b600080516020610527833981519152546001600160a01b0316336001600160a01b0316146101d45760405162461bcd60e51b815260040161017f906104df565b6101dd836102f9565b6000306001600160a01b03163484846040516101fa929190610516565b60006040518083038185875af1925050503d8060008114610237576040519150601f19603f3d011682016040523d82523d6000602084013e61023c565b606091505b505090508061028d5760405162461bcd60e51b815260206004820181905260248201527f4549503139363750726f78793a207570646174652063616c6c206661696c6564604482015260640161017f565b50505050565b600080516020610527833981519152546001600160a01b0316336001600160a01b0316146102d35760405162461bcd60e51b815260040161017f906104df565b61019181610388565b60006102f46000805160206105278339815191525490565b905090565b6001600160a01b03811661030c57600080fd5b806001600160a01b031661032c6000805160206105478339815191525490565b6001600160a01b03160361033f57600080fd5b6000805160206105478339815191528190556040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60006103926102dc565b90506001600160a01b0382166103a757600080fd5b816001600160a01b0316816001600160a01b0316036103c557600080fd5b600080516020610527833981519152829055604080516001600160a01b038084168252841660208201527f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a15050565b80356001600160a01b038116811461043557600080fd5b919050565b60006020828403121561044c57600080fd5b6104558261041e565b9392505050565b60008060006040848603121561047157600080fd5b61047a8461041e565b9250602084013567ffffffffffffffff8082111561049757600080fd5b818601915086601f8301126104ab57600080fd5b8135818111156104ba57600080fd5b8760208285010111156104cc57600080fd5b6020830194508093505050509250925092565b6020808252601a908201527f4549503139363741646d696e3a206e6f7420616e2061646d696e000000000000604082015260600190565b818382376000910190815291905056feb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca26469706673582212203a120e4dd5f0849a0b6e92c874b8ff4e42363c90d20d52f4cac638a68ae33dcb64736f6c634300080f0033b53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc00000000000000000000000039f0bd56c1439a22ee90b4972c16b7868d161981000000000000000000000000000000000000000000000000000000000000dead00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000
Deployed ByteCode
0x60806040526004361061004a5760003560e01c80633659cfe61461009d5780634f1ef286146100bd5780635c60da1b146100d0578063704b6c021461010a578063f851a4401461012a575b60006100626000805160206105478339815191525490565b90506001600160a01b03811661007757600080fd5b3660008037600080366000845af43d6000803e808015610096573d6000f35b3d6000fd5b005b3480156100a957600080fd5b5061009b6100b836600461043a565b61013f565b61009b6100cb36600461045c565b610194565b3480156100dc57600080fd5b50600080516020610547833981519152545b6040516001600160a01b03909116815260200160405180910390f35b34801561011657600080fd5b5061009b61012536600461043a565b610293565b34801561013657600080fd5b506100ee6102dc565b600080516020610527833981519152546001600160a01b0316336001600160a01b0316146101885760405162461bcd60e51b815260040161017f906104df565b60405180910390fd5b610191816102f9565b50565b600080516020610527833981519152546001600160a01b0316336001600160a01b0316146101d45760405162461bcd60e51b815260040161017f906104df565b6101dd836102f9565b6000306001600160a01b03163484846040516101fa929190610516565b60006040518083038185875af1925050503d8060008114610237576040519150601f19603f3d011682016040523d82523d6000602084013e61023c565b606091505b505090508061028d5760405162461bcd60e51b815260206004820181905260248201527f4549503139363750726f78793a207570646174652063616c6c206661696c6564604482015260640161017f565b50505050565b600080516020610527833981519152546001600160a01b0316336001600160a01b0316146102d35760405162461bcd60e51b815260040161017f906104df565b61019181610388565b60006102f46000805160206105278339815191525490565b905090565b6001600160a01b03811661030c57600080fd5b806001600160a01b031661032c6000805160206105478339815191525490565b6001600160a01b03160361033f57600080fd5b6000805160206105478339815191528190556040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60006103926102dc565b90506001600160a01b0382166103a757600080fd5b816001600160a01b0316816001600160a01b0316036103c557600080fd5b600080516020610527833981519152829055604080516001600160a01b038084168252841660208201527f7e644d79422f17c01e4894b5f4f588d331ebfa28653d42ae832dc59e38c9798f910160405180910390a15050565b80356001600160a01b038116811461043557600080fd5b919050565b60006020828403121561044c57600080fd5b6104558261041e565b9392505050565b60008060006040848603121561047157600080fd5b61047a8461041e565b9250602084013567ffffffffffffffff8082111561049757600080fd5b818601915086601f8301126104ab57600080fd5b8135818111156104ba57600080fd5b8760208285010111156104cc57600080fd5b6020830194508093505050509250925092565b6020808252601a908201527f4549503139363741646d696e3a206e6f7420616e2061646d696e000000000000604082015260600190565b818382376000910190815291905056feb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca26469706673582212203a120e4dd5f0849a0b6e92c874b8ff4e42363c90d20d52f4cac638a68ae33dcb64736f6c634300080f0033