Skip to content
Verified contractExactMIT

Proxy

Address0xa8d435794b1d73e6972bbac07f260d4577a98534
Balance

0.056948 ETH

 

Transactions

152

 

Compiler

solc 0.8.1

 

Same code

2 more contracts

 

Details

Compiler
solc 0.8.1+commit.df193b15
Language
solidity
Optimization
No
EVM version
istanbul
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
12,155,257
Creation transaction
0x9c507b7242…f34857f4e8
Proxy implementation
0xcee66def…b9c763feSwapAll

2 files

Proxy.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;

import "./Ownable.sol";

contract Proxy is Ownable {

    bytes32 private constant targetPosition = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    constructor(address target) Ownable(msg.sender) {
        setTarget(target);
    }

    function getTarget() public view returns (address target) {
        bytes32 position = targetPosition;
        assembly {
            target := sload(position)
        }
    }

    function setTarget(address newTarget) internal onlyOwner {
        bytes32 position = targetPosition;
        assembly {
            sstore(position, newTarget)
        }
    }

    function upgradeTarget(address newTarget) public onlyOwner {
        setTarget(newTarget);
    }

    receive() external payable {}

    fallback() external payable onlyOwner {
        address _target = getTarget();
        assembly {
            let ptr := mload(0x40)
            calldatacopy(ptr, 0x0, calldatasize())
            let result := delegatecall(gas(), _target, ptr, calldatasize(), 0x0,0)
            let size := returndatasize()
            returndatacopy(ptr, 0x0, size)
            switch result
            case 0 {
                revert(ptr, size)
            }
            default {
                return(ptr, size)
            }
        }
    }
}

Ownable.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
contract Ownable {
    bytes32 private constant ownerPosition = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    constructor(address ownerAddress) {
        setOwner(ownerAddress);
    }

    function setOwner(address newOwner) internal {
        bytes32 position = ownerPosition;
        assembly {
            sstore(position, newOwner)
        }
    }

    function getOwner() public view returns (address owner) {
        bytes32 position = ownerPosition;
        assembly {
            owner := sload(position)
        }
    }

    modifier onlyOwner() {
        require(msg.sender == getOwner());
        _;
    }

    function transferOwnership(address newOwner) public onlyOwner {
        require(newOwner != address(0));
        setOwner(newOwner);
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": false
  },
  "evmVersion": "istanbul",
  "remappings": []
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.