Contract Overview
Balance:
0 Ether
More Info
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Contract Name:
WitnetProxy
Compiler Version
v0.8.6+commit.11564f7e
Contract Source Code (Solidity)
/** *Submitted for verification at Etherscan.io on 2021-08-24 */ // SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.9.0; pragma experimental ABIEncoderV2; // File: contracts\patterns\Initializable.sol interface Initializable { /// @dev Initialize contract's storage context. function initialize(bytes calldata) external; } // File: contracts\patterns\Proxiable.sol interface Proxiable { /// @dev Complying with EIP-1822: Universal Upgradable Proxy Standard (UUPS) /// @dev See https://eips.ethereum.org/EIPS/eip-1822. function proxiableUUID() external pure returns (bytes32); } // File: contracts\patterns\Upgradable.sol /* solhint-disable var-name-mixedcase */ abstract contract Upgradable is Initializable, Proxiable { address internal immutable _BASE; bytes32 internal immutable _CODEHASH; bool internal immutable _UPGRADABLE; /// Emitted every time the contract gets upgraded. /// @param from The address who ordered the upgrading. Namely, the WRB operator in "trustable" implementations. /// @param baseAddr The address of the new implementation contract. /// @param baseCodehash The EVM-codehash of the new implementation contract. /// @param versionTag Ascii-encoded version literal with which the implementation deployer decided to tag it. event Upgraded( address indexed from, address indexed baseAddr, bytes32 indexed baseCodehash, bytes32 versionTag ); constructor (bool _isUpgradable) { address _base = address(this); bytes32 _codehash; assembly { _codehash := extcodehash(_base) } _BASE = _base; _CODEHASH = _codehash; _UPGRADABLE = _isUpgradable; } /// @dev Tells whether provided address could eventually upgrade the contract. function isUpgradableFrom(address from) virtual external view returns (bool); /// TODO: the following methods should be all declared as pure /// whenever this Solidity's PR gets merged and released: /// https://github.com/ethereum/solidity/pull/10240 /// @dev Retrieves base contract. Differs from address(this) when via delegate-proxy pattern. function base() public view returns (address) { return _BASE; } /// @dev Retrieves the immutable codehash of this contract, even if invoked as delegatecall. /// @return _codehash This contracts immutable codehash. function codehash() public view returns (bytes32 _codehash) { return _CODEHASH; } /// @dev Determines whether current instance allows being upgraded. /// @dev Returned value should be invariant from whoever is calling. function isUpgradable() public view returns (bool) { return _UPGRADABLE; } /// @dev Retrieves human-redable named version of current implementation. function version() virtual public view returns (bytes32); } // File: contracts\impls\WitnetProxy.sol /// @title WitnetProxy: upgradable delegate-proxy contract that routes Witnet data requests coming from a /// `UsingWitnet`-inheriting contract to a currently active `WitnetRequestBoard` implementation. /// https://github.com/witnet/witnet-ethereum-bridge/tree/0.3.x /// @author The Witnet Foundation. contract WitnetProxy { struct WitnetProxySlot { address implementation; } /// Event emitted when a new DR is posted. event Upgraded(address indexed implementation); /// Constructor with no params as to ease eventual support of Singleton pattern (i.e. ERC-2470). constructor () {} /// WitnetProxies will never accept direct transfer of ETHs. receive() external payable { revert("WitnetProxy: no transfers accepted"); } /// Payable fallback accepts delegating calls to payable functions. fallback() external payable { /* solhint-disable no-complex-fallback */ address _implementation = implementation(); assembly { /* solhint-disable avoid-low-level-calls */ // Gas optimized delegate call to 'implementation' contract. // Note: `msg.data`, `msg.sender` and `msg.value` will be passed over // to actual implementation of `msg.sig` within `implementation` contract. let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _implementation, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { // pass back revert message: revert(ptr, size) } default { // pass back same data as returned by 'implementation' contract: return(ptr, size) } } } /// Returns proxy's current implementation address. function implementation() public view returns (address) { return _proxySlot().implementation; } /// Upgrades the `implementation` address. /// @param _newImplementation New implementation address. /// @param _initData Raw data with which new implementation will be initialized. /// @return Returns whether new implementation would be further upgradable, or not. function upgradeTo(address _newImplementation, bytes memory _initData) public returns (bool) { // New implementation cannot be null: require(_newImplementation != address(0), "WitnetProxy: null implementation"); address _oldImplementation = implementation(); if (_oldImplementation != address(0)) { // New implementation address must differ from current one: require(_newImplementation != _oldImplementation, "WitnetProxy: nothing to upgrade"); // Assert whether current implementation is intrinsically upgradable: try Upgradable(_oldImplementation).isUpgradable() returns (bool _isUpgradable) { require(_isUpgradable, "WitnetProxy: not upgradable"); } catch { revert("WitnetProxy: unable to check upgradability"); } // Assert whether current implementation allows `msg.sender` to upgrade the proxy: (bool _wasCalled, bytes memory _result) = _oldImplementation.delegatecall( abi.encodeWithSignature( "isUpgradableFrom(address)", msg.sender ) ); require(_wasCalled, "WitnetProxy: not compliant"); require(abi.decode(_result, (bool)), "WitnetProxy: not authorized"); require( Upgradable(_oldImplementation).proxiableUUID() == Upgradable(_newImplementation).proxiableUUID(), "WitnetProxy: proxiableUUIDs mismatch" ); } // Initialize new implementation within proxy-context storage: (bool _wasInitialized,) = _newImplementation.delegatecall( abi.encodeWithSignature( "initialize(bytes)", _initData ) ); require(_wasInitialized, "WitnetProxy: unable to initialize"); // If all checks and initialization pass, update implementation address: _proxySlot().implementation = _newImplementation; emit Upgraded(_newImplementation); // Asserts new implementation complies w/ minimal implementation of Upgradable interface: try Upgradable(_newImplementation).isUpgradable() returns (bool _isUpgradable) { return _isUpgradable; } catch { revert ("WitnetProxy: not compliant"); } } /// @dev Complying with EIP-1967, retrieves storage struct containing proxy's current implementation address. function _proxySlot() private pure returns (WitnetProxySlot storage _slot) { assembly { // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) _slot.slot := 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc } } }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newImplementation","type":"address"},{"internalType":"bytes","name":"_initData","type":"bytes"}],"name":"upgradeTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b506109ac806100206000396000f3fe60806040526004361061002d5760003560e01c80635c60da1b146100bb5780636fbc15e9146100ed5761008a565b3661008a5760405162461bcd60e51b815260206004820152602260248201527f5769746e657450726f78793a206e6f207472616e736665727320616363657074604482015261195960f21b60648201526084015b60405180910390fd5b600061009461011d565b905060405136600082376000803683855af43d806000843e8180156100b7578184f35b8184fd5b3480156100c757600080fd5b506100d061011d565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156100f957600080fd5b5061010d6101083660046107cf565b61014b565b60405190151581526020016100e4565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b60006001600160a01b0383166101a35760405162461bcd60e51b815260206004820181905260248201527f5769746e657450726f78793a206e756c6c20696d706c656d656e746174696f6e6044820152606401610081565b60006101ad61011d565b90506001600160a01b038116156105b757806001600160a01b0316846001600160a01b031614156102205760405162461bcd60e51b815260206004820152601f60248201527f5769746e657450726f78793a206e6f7468696e6720746f2075706772616465006044820152606401610081565b806001600160a01b0316635479d9406040518163ffffffff1660e01b815260040160206040518083038186803b15801561025957600080fd5b505afa925050508015610289575060408051601f3d908101601f191682019092526102869181019061089f565b60015b6102e85760405162461bcd60e51b815260206004820152602a60248201527f5769746e657450726f78793a20756e61626c6520746f20636865636b207570676044820152697261646162696c69747960b01b6064820152608401610081565b806103355760405162461bcd60e51b815260206004820152601b60248201527f5769746e657450726f78793a206e6f742075706772616461626c6500000000006044820152606401610081565b5060405133602482015260009081906001600160a01b0384169060440160408051601f198184030181529181526020820180516001600160e01b03166335ac4b0560e11b1790525161038791906108e1565b600060405180830381855af49150503d80600081146103c2576040519150601f19603f3d011682016040523d82523d6000602084013e6103c7565b606091505b5091509150816104195760405162461bcd60e51b815260206004820152601a60248201527f5769746e657450726f78793a206e6f7420636f6d706c69616e740000000000006044820152606401610081565b8080602001905181019061042d919061089f565b6104795760405162461bcd60e51b815260206004820152601b60248201527f5769746e657450726f78793a206e6f7420617574686f72697a656400000000006044820152606401610081565b856001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b1580156104b257600080fd5b505afa1580156104c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ea91906108c8565b836001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561052357600080fd5b505afa158015610537573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061055b91906108c8565b146105b45760405162461bcd60e51b8152602060048201526024808201527f5769746e657450726f78793a2070726f786961626c655555494473206d69736d6044820152630c2e8c6d60e31b6064820152608401610081565b50505b6000846001600160a01b0316846040516024016105d491906108fd565b60408051601f198184030181529181526020820180516001600160e01b031663439fab9160e01b1790525161060991906108e1565b600060405180830381855af49150503d8060008114610644576040519150601f19603f3d011682016040523d82523d6000602084013e610649565b606091505b50509050806106a45760405162461bcd60e51b815260206004820152602160248201527f5769746e657450726f78793a20756e61626c6520746f20696e697469616c697a6044820152606560f81b6064820152608401610081565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0387169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2846001600160a01b0316635479d9406040518163ffffffff1660e01b815260040160206040518083038186803b15801561074357600080fd5b505afa925050508015610773575060408051601f3d908101601f191682019092526107709181019061089f565b60015b6107bf5760405162461bcd60e51b815260206004820152601a60248201527f5769746e657450726f78793a206e6f7420636f6d706c69616e740000000000006044820152606401610081565b92506107c9915050565b92915050565b600080604083850312156107e257600080fd5b82356001600160a01b03811681146107f957600080fd5b9150602083013567ffffffffffffffff8082111561081657600080fd5b818501915085601f83011261082a57600080fd5b81358181111561083c5761083c610960565b604051601f8201601f19908116603f0116810190838211818310171561086457610864610960565b8160405282815288602084870101111561087d57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000602082840312156108b157600080fd5b815180151581146108c157600080fd5b9392505050565b6000602082840312156108da57600080fd5b5051919050565b600082516108f3818460208701610930565b9190910192915050565b602081526000825180602084015261091c816040850160208701610930565b601f01601f19169190910160400192915050565b60005b8381101561094b578181015183820152602001610933565b8381111561095a576000848401525b50505050565b634e487b7160e01b600052604160045260246000fdfea26469706673582212207017ba577d0791dad8a4a18371ddfbd7e43d3962cbb9709032c9b442aa5b164f64736f6c63430008060033
Deployed ByteCode Sourcemap
3328:4958:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;3766:44;;-1:-1:-1;;;3766:44:0;;3254:2:1;3766:44:0;;;3236:21:1;3293:2;3273:18;;;3266:30;3332:34;3312:18;;;3305:62;-1:-1:-1;;;3383:18:1;;;3376:32;3425:19;;3766:44:0;;;;;;;;3328:4958;3982:23;4008:16;:14;:16::i;:::-;3982:42;;4374:4;4368:11;4414:14;4411:1;4406:3;4393:36;4518:1;4515;4499:14;4494:3;4477:15;4470:5;4457:63;4546:16;4599:4;4596:1;4591:3;4576:28;4625:6;4649:119;;;;4911:4;4906:3;4899:17;4649:119;4743:4;4738:3;4731:17;5019:109;;;;;;;;;;;;;:::i;:::-;;;-1:-1:-1;;;;;2028:32:1;;;2010:51;;1998:2;1983:18;5019:109:0;;;;;;;;5422:2448;;;;;;;;;;-1:-1:-1;5422:2448:0;;;;;:::i;:::-;;:::i;:::-;;;2237:14:1;;2230:22;2212:41;;2200:2;2185:18;5422:2448:0;2167:92:1;5019:109:0;8197:66;5093:27;-1:-1:-1;;;;;5093:27:0;;5019:109::o;5422:2448::-;5518:4;-1:-1:-1;;;;;5595:32:0;;5587:77;;;;-1:-1:-1;;;5587:77:0;;4424:2:1;5587:77:0;;;4406:21:1;;;4443:18;;;4436:30;4502:34;4482:18;;;4475:62;4554:18;;5587:77:0;4396:182:1;5587:77:0;5677:26;5706:16;:14;:16::i;:::-;5677:45;-1:-1:-1;;;;;;5737:32:0;;;5733:1282;;5889:18;-1:-1:-1;;;;;5867:40:0;:18;-1:-1:-1;;;;;5867:40:0;;;5859:84;;;;-1:-1:-1;;;5859:84:0;;5141:2:1;5859:84:0;;;5123:21:1;5180:2;5160:18;;;5153:30;5219:33;5199:18;;;5192:61;5270:18;;5859:84:0;5113:181:1;5859:84:0;6058:18;-1:-1:-1;;;;;6047:43:0;;:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;6047:45:0;;;;;;;;-1:-1:-1;;6047:45:0;;;;;;;;;;;;:::i;:::-;;;6043:261;;6236:52;;-1:-1:-1;;;6236:52:0;;3657:2:1;6236:52:0;;;3639:21:1;3696:2;3676:18;;;3669:30;3735:34;3715:18;;;3708:62;-1:-1:-1;;;3786:18:1;;;3779:40;3836:19;;6236:52:0;3629:232:1;6043:261:0;6149:13;6141:53;;;;-1:-1:-1;;;6141:53:0;;4785:2:1;6141:53:0;;;4767:21:1;4824:2;4804:18;;;4797:30;4863:29;4843:18;;;4836:57;4910:18;;6141:53:0;4757:177:1;6141:53:0;-1:-1:-1;6508:125:0;;6604:10;6508:125;;;2010:51:1;6417:15:0;;;;-1:-1:-1;;;;;6458:31:0;;;1983:18:1;;6508:125:0;;;-1:-1:-1;;6508:125:0;;;;;;;;;;;;;;-1:-1:-1;;;;;6508:125:0;-1:-1:-1;;;6508:125:0;;;6458:190;;;6508:125;6458:190;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6416:232;;;;6671:10;6663:49;;;;-1:-1:-1;;;6663:49:0;;5906:2:1;6663:49:0;;;5888:21:1;5945:2;5925:18;;;5918:30;5984:28;5964:18;;;5957:56;6030:18;;6663:49:0;5878:176:1;6663:49:0;6746:7;6735:27;;;;;;;;;;;;:::i;:::-;6727:67;;;;-1:-1:-1;;;6727:67:0;;4068:2:1;6727:67:0;;;4050:21:1;4107:2;4087:18;;;4080:30;4146:29;4126:18;;;4119:57;4193:18;;6727:67:0;4040:177:1;6727:67:0;6896:18;-1:-1:-1;;;;;6885:44:0;;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;6846:18;-1:-1:-1;;;;;6835:44:0;;:46;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:96;6809:194;;;;-1:-1:-1;;;6809:194:0;;5501:2:1;6809:194:0;;;5483:21:1;5540:2;5520:18;;;5513:30;5579:34;5559:18;;;5552:62;-1:-1:-1;;;5630:18:1;;;5623:34;5674:19;;6809:194:0;5473:226:1;6809:194:0;5771:1244;;5733:1282;7100:20;7125:18;-1:-1:-1;;;;;7125:31:0;7251:9;7171:104;;;;;;;;:::i;:::-;;;;-1:-1:-1;;7171:104:0;;;;;;;;;;;;;;-1:-1:-1;;;;;7171:104:0;-1:-1:-1;;;7171:104:0;;;7125:161;;;7171:104;7125:161;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7099:187;;;7305:15;7297:61;;;;-1:-1:-1;;;7297:61:0;;2852:2:1;7297:61:0;;;2834:21:1;2891:2;2871:18;;;2864:30;2930:34;2910:18;;;2903:62;-1:-1:-1;;;2981:18:1;;;2974:31;3022:19;;7297:61:0;2824:223:1;7297:61:0;8197:66;7453:48;;-1:-1:-1;;;;;;7453:48:0;-1:-1:-1;;;;;7453:48:0;;;;;;;;7517:28;;;;-1:-1:-1;;7517:28:0;7672:18;-1:-1:-1;;;;;7661:43:0;;:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;7661:45:0;;;;;;;;-1:-1:-1;;7661:45:0;;;;;;;;;;;;:::i;:::-;;;7657:206;;7814:37;;-1:-1:-1;;;7814:37:0;;5906:2:1;7814:37:0;;;5888:21:1;5945:2;5925:18;;;5918:30;5984:28;5964:18;;;5957:56;6030:18;;7814:37:0;5878:176:1;7657:206:0;7758:13;-1:-1:-1;7751:20:0;;-1:-1:-1;;7751:20:0;5422:2448;;;;;:::o;14:1095:1:-;91:6;99;152:2;140:9;131:7;127:23;123:32;120:2;;;168:1;165;158:12;120:2;194:23;;-1:-1:-1;;;;;246:31:1;;236:42;;226:2;;292:1;289;282:12;226:2;315:5;-1:-1:-1;371:2:1;356:18;;343:32;394:18;424:14;;;421:2;;;451:1;448;441:12;421:2;489:6;478:9;474:22;464:32;;534:7;527:4;523:2;519:13;515:27;505:2;;556:1;553;546:12;505:2;592;579:16;614:2;610;607:10;604:2;;;620:18;;:::i;:::-;695:2;689:9;663:2;749:13;;-1:-1:-1;;745:22:1;;;769:2;741:31;737:40;725:53;;;793:18;;;813:22;;;790:46;787:2;;;839:18;;:::i;:::-;879:10;875:2;868:22;914:2;906:6;899:18;954:7;949:2;944;940;936:11;932:20;929:33;926:2;;;975:1;972;965:12;926:2;1031;1026;1022;1018:11;1013:2;1005:6;1001:15;988:46;1076:1;1071:2;1066;1058:6;1054:15;1050:24;1043:35;1097:6;1087:16;;;;;;;110:999;;;;;:::o;1114:277::-;1181:6;1234:2;1222:9;1213:7;1209:23;1205:32;1202:2;;;1250:1;1247;1240:12;1202:2;1282:9;1276:16;1335:5;1328:13;1321:21;1314:5;1311:32;1301:2;;1357:1;1354;1347:12;1301:2;1380:5;1192:199;-1:-1:-1;;;1192:199:1:o;1396:184::-;1466:6;1519:2;1507:9;1498:7;1494:23;1490:32;1487:2;;;1535:1;1532;1525:12;1487:2;-1:-1:-1;1558:16:1;;1477:103;-1:-1:-1;1477:103:1:o;1585:274::-;1714:3;1752:6;1746:13;1768:53;1814:6;1809:3;1802:4;1794:6;1790:17;1768:53;:::i;:::-;1837:16;;;;;1722:137;-1:-1:-1;;1722:137:1:o;2264:381::-;2411:2;2400:9;2393:21;2374:4;2443:6;2437:13;2486:6;2481:2;2470:9;2466:18;2459:34;2502:66;2561:6;2556:2;2545:9;2541:18;2536:2;2528:6;2524:15;2502:66;:::i;:::-;2629:2;2608:15;-1:-1:-1;;2604:29:1;2589:45;;;;2636:2;2585:54;;2383:262;-1:-1:-1;;2383:262:1:o;6059:258::-;6131:1;6141:113;6155:6;6152:1;6149:13;6141:113;;;6231:11;;;6225:18;6212:11;;;6205:39;6177:2;6170:10;6141:113;;;6272:6;6269:1;6266:13;6263:2;;;6307:1;6298:6;6293:3;6289:16;6282:27;6263:2;;6112:205;;;:::o;6322:127::-;6383:10;6378:3;6374:20;6371:1;6364:31;6414:4;6411:1;6404:15;6438:4;6435:1;6428:15
Swarm Source
ipfs://7017ba577d0791dad8a4a18371ddfbd7e43d3962cbb9709032c9b442aa5b164f
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.