false
false
0

Contract Address Details

0x407B23Dad0bD32a3B1Ad184A2e61c206615F7771

Contract Name
VersionManager
Creator
0x331cdb–09a67c at 0x9bea8a–49a87a
Balance
0 BPX
Tokens
Fetching tokens...
Transactions
2 Transactions
Transfers
0 Transfers
Gas Used
236,120
Last Balance Update
202013
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
VersionManager




Optimization enabled
false
Compiler version
v0.8.28+commit.7893614a




EVM Version
shanghai




Verified at
2024-12-26T12:40:42.621953Z

Contract source code

Sol2uml
new
// File: bitpost-contracts/contracts-common/interfaces/access/IOwnable.sol



pragma solidity ^0.8.20;

interface IOwnable {
    error OwnableUnauthorized(address sender, address owner);
    error OwnableInvalidOwner(address owner);
    
    function getOwner() external view returns(address);
    function setOwner(address owner) external;
}

// File: bitpost-contracts/contracts-common/contracts/access/Ownable.sol



pragma solidity ^0.8.20;


abstract contract Ownable is IOwnable {
    /// @custom:storage-location erc7201:bitpost.common.Ownable
    struct Storage_Ownable {
        address owner;
    }
    
    // keccak256(abi.encode(uint256(keccak256("bitpost.common.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant STORAGE_LOCATION_OWNABLE = 0xbfdc26bbaea09886fc184fe4fcae59b15cffdf4b859be87d5955dbd541465600;
    
    modifier onlyOwner() {
        _checkOwner();
        _;
    }
    
    function _init_Ownable(address owner) internal {
        _setOwner(owner);
    }
    
    function getOwner() public view returns(address) {
        Storage_Ownable storage $ = _getStorage_Ownable();
        return $.owner;
    }
    
    function setOwner(address owner) external onlyOwner {
        _setOwner(owner);
    }
    
    function _setOwner(address owner) internal {
        require(owner != address(0), OwnableInvalidOwner(address(0)));
        Storage_Ownable storage $ = _getStorage_Ownable();
        $.owner = owner;
    }
    
    function _checkOwner() private view {
        Storage_Ownable storage $ = _getStorage_Ownable();
        require(msg.sender == $.owner, OwnableUnauthorized(msg.sender, $.owner));
    }
    
    function _getStorage_Ownable() private pure returns(Storage_Ownable storage $) {
        assembly {
            $.slot := STORAGE_LOCATION_OWNABLE
        }
    }
}

// File: bitpost-contracts/contracts-vm/interfaces/IVersionManager.sol



pragma solidity ^0.8.20;


interface IVersionManager is IOwnable {
    error VersionManagerInvalidCid(uint16 cid);
    
    function getImplementation(uint16 cid) external view returns(address);
    function setImplementation(uint16 cid, address implementation) external;
    function newContract(uint16 cid) external returns(address);
}

// File: bitpost-contracts/contracts-common/contracts/upgrade/Upgradeable.sol



pragma solidity ^0.8.20;


abstract contract Upgradeable {
    /// @custom:storage-location erc7201:bitpost.common.Upgradeable
    struct Storage_Upgradeable {
        IVersionManager versionManager;
        uint16 cid;
    }
    
    // keccak256(abi.encode(uint256(keccak256("bitpost.common.Upgradeable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant STORAGE_LOCATION_UPGRADEABLE = 0x828626e98fd64181cb42e58a50c4931f9ea11da1800ee5ae64b4a2a58285ae00;
    
    function _init_Upgradeable(IVersionManager versionManager, uint16 cid) internal {
        Storage_Upgradeable storage $ = _getStorage_Upgradeable();
        $.versionManager = versionManager;
        $.cid = cid;
    }
    
    function _getVersionManager() internal view returns(IVersionManager) {
        Storage_Upgradeable storage $ = _getStorage_Upgradeable();
        return $.versionManager;
    }
    
    function _getCid() internal view returns(uint16) {
        Storage_Upgradeable storage $ = _getStorage_Upgradeable();
        return $.cid;
    }
    
    function _getStorage_Upgradeable() private pure returns(Storage_Upgradeable storage $) {
        assembly {
            $.slot := STORAGE_LOCATION_UPGRADEABLE
        }
    }
}

// File: bitpost-contracts/contracts-vm/contracts/proxy/Proxy.sol



pragma solidity ^0.8.20;



contract Proxy is Upgradeable {
    constructor(VersionManager versionManager, uint16 cid) {
        _init_Upgradeable(versionManager, cid);
    }
    
    fallback() external payable {
        address target = _getVersionManager().getImplementation(_getCid());
        
        // The target address is stored on the stack, not in memory, 
        // so it won't be affected by operations using memory offset 0.
        
        assembly {
            calldatacopy(0, 0, calldatasize())
            let result := delegatecall(gas(), target, 0, calldatasize(), 0, 0)
            returndatacopy(0, 0, returndatasize())
            
            switch result
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }
        }
    }
}

// File: bitpost-contracts/contracts-vm/contracts/VersionManager.sol



pragma solidity ^0.8.20;




contract VersionManager is IVersionManager, Ownable {
    /// @custom:storage-location erc7201:bitpost.vm.VersionManager
    struct Storage_VersionManager {
        mapping(uint16 => address) implementations;
    }
    
    // keccak256(abi.encode(uint256(keccak256("bitpost.vm.VersionManager")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant STORAGE_LOCATION_VERSIONMANAGER = 0x433f1e912c5d27d7a45609db3e669bf6cc6b4b451297228e4c27368efb8c2300;
    
    constructor() {
        _init_Ownable(msg.sender);
    }
    
    function getImplementation(uint16 cid) external view returns(address) {
        Storage_VersionManager storage $ = _getStorage_VersionManager();
        require($.implementations[cid] != address(0), VersionManagerInvalidCid(cid));
        return $.implementations[cid];
    }
    
    function setImplementation(uint16 cid, address implementation) external onlyOwner {
        Storage_VersionManager storage $ = _getStorage_VersionManager();
        $.implementations[cid] = implementation;
    }
    
    function newContract(uint16 cid) external returns(address) {
        Storage_VersionManager storage $ = _getStorage_VersionManager();
        require($.implementations[cid] != address(0), VersionManagerInvalidCid(cid));
        return address(new Proxy(this, cid));
    }
    
    function _getStorage_VersionManager() private pure returns(Storage_VersionManager storage $) {
        assembly {
            $.slot := STORAGE_LOCATION_VERSIONMANAGER
        }
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorized","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"VersionManagerInvalidCid","inputs":[{"type":"uint16","name":"cid","internalType":"uint16"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getImplementation","inputs":[{"type":"uint16","name":"cid","internalType":"uint16"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getOwner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"newContract","inputs":[{"type":"uint16","name":"cid","internalType":"uint16"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setImplementation","inputs":[{"type":"uint16","name":"cid","internalType":"uint16"},{"type":"address","name":"implementation","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]}]
              

Contract Creation Code

Verify & Publish
0x608060405234801561000f575f5ffd5b5061001f3361002460201b60201c565b61017e565b6100338161003660201b60201c565b50565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155f906100a8576040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161009f9190610165565b60405180910390fd5b505f6100b86100ff60201b60201c565b905081815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b5f7fbfdc26bbaea09886fc184fe4fcae59b15cffdf4b859be87d5955dbd541465600905090565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61014f82610126565b9050919050565b61015f81610145565b82525050565b5f6020820190506101785f830184610156565b92915050565b610be88061018b5f395ff3fe608060405234801561000f575f5ffd5b5060043610610055575f3560e01c806313af40351461005957806358fb826b14610075578063893d20e8146100a55780639873400e146100c3578063d2255403146100f3575b5f5ffd5b610073600480360381019061006e91906105f9565b61010f565b005b61008f600480360381019061008a919061065b565b610123565b60405161009c9190610695565b60405180910390f35b6100ad610216565b6040516100ba9190610695565b60405180910390f35b6100dd60048036038101906100d8919061065b565b61024b565b6040516100ea9190610695565b60405180910390f35b61010d600480360381019061010891906106ae565b610345565b005b6101176103b5565b6101208161047d565b50565b5f5f61012d610540565b90505f73ffffffffffffffffffffffffffffffffffffffff16815f015f8561ffff1661ffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141583906101da576040517f6e0eba3b0000000000000000000000000000000000000000000000000000000081526004016101d191906106fb565b60405180910390fd5b5030836040516101e99061058e565b6101f492919061076f565b604051809103905ff08015801561020d573d5f5f3e3d5ffd5b50915050919050565b5f5f610220610567565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b5f5f610255610540565b90505f73ffffffffffffffffffffffffffffffffffffffff16815f015f8561ffff1661ffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614158390610302576040517f6e0eba3b0000000000000000000000000000000000000000000000000000000081526004016102f991906106fb565b60405180910390fd5b50805f015f8461ffff1661ffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b61034d6103b5565b5f610356610540565b905081815f015f8561ffff1661ffff1681526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b5f6103be610567565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161433825f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169091610478576040517f0992ea8300000000000000000000000000000000000000000000000000000000815260040161046f929190610796565b60405180910390fd5b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155f906104ef576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016104e69190610695565b60405180910390fd5b505f6104f9610567565b905081815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b5f7f433f1e912c5d27d7a45609db3e669bf6cc6b4b451297228e4c27368efb8c2300905090565b5f7fbfdc26bbaea09886fc184fe4fcae59b15cffdf4b859be87d5955dbd541465600905090565b6103f5806107be83390190565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6105c88261059f565b9050919050565b6105d8816105be565b81146105e2575f5ffd5b50565b5f813590506105f3816105cf565b92915050565b5f6020828403121561060e5761060d61059b565b5b5f61061b848285016105e5565b91505092915050565b5f61ffff82169050919050565b61063a81610624565b8114610644575f5ffd5b50565b5f8135905061065581610631565b92915050565b5f602082840312156106705761066f61059b565b5b5f61067d84828501610647565b91505092915050565b61068f816105be565b82525050565b5f6020820190506106a85f830184610686565b92915050565b5f5f604083850312156106c4576106c361059b565b5b5f6106d185828601610647565b92505060206106e2858286016105e5565b9150509250929050565b6106f581610624565b82525050565b5f60208201905061070e5f8301846106ec565b92915050565b5f819050919050565b5f61073761073261072d8461059f565b610714565b61059f565b9050919050565b5f6107488261071d565b9050919050565b5f6107598261073e565b9050919050565b6107698161074f565b82525050565b5f6040820190506107825f830185610760565b61078f60208301846106ec565b9392505050565b5f6040820190506107a95f830185610686565b6107b66020830184610686565b939250505056fe608060405234801561000f575f5ffd5b506040516103f53803806103f58339818101604052810190610031919061018a565b610041828261004860201b60201c565b50506101c8565b5f6100576100bd60201b60201c565b905082815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081815f0160146101000a81548161ffff021916908361ffff160217905550505050565b5f7f828626e98fd64181cb42e58a50c4931f9ea11da1800ee5ae64b4a2a58285ae00905090565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610111826100e8565b9050919050565b5f61012282610107565b9050919050565b61013281610118565b811461013c575f5ffd5b50565b5f8151905061014d81610129565b92915050565b5f61ffff82169050919050565b61016981610153565b8114610173575f5ffd5b50565b5f8151905061018481610160565b92915050565b5f5f604083850312156101a05761019f6100e4565b5b5f6101ad8582860161013f565b92505060206101be85828601610176565b9150509250929050565b610220806101d55f395ff3fe60806040525f61000d6100ac565b73ffffffffffffffffffffffffffffffffffffffff16639873400e6100306100e1565b6040518263ffffffff1660e01b815260040161004c9190610148565b602060405180830381865afa158015610067573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061008b91906101bf565b9050365f5f375f5f365f845af43d5f5f3e805f81146100a8573d5ff35b3d5ffd5b5f5f6100b6610105565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b5f5f6100eb610105565b9050805f0160149054906101000a900461ffff1691505090565b5f7f828626e98fd64181cb42e58a50c4931f9ea11da1800ee5ae64b4a2a58285ae00905090565b5f61ffff82169050919050565b6101428161012c565b82525050565b5f60208201905061015b5f830184610139565b92915050565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61018e82610165565b9050919050565b61019e81610184565b81146101a8575f5ffd5b50565b5f815190506101b981610195565b92915050565b5f602082840312156101d4576101d3610161565b5b5f6101e1848285016101ab565b9150509291505056fea26469706673582212205ea8572b2dc4952057aa047c7aa2c5ab28dfdae8fec0a824bf2f165add8790a764736f6c634300081c0033a26469706673582212200dfbaa80ed868e9e7551a63fcf10d02f51faca90f731fe8f24ef59eb97e0e85664736f6c634300081c0033

Deployed ByteCode

0x608060405234801561000f575f5ffd5b5060043610610055575f3560e01c806313af40351461005957806358fb826b14610075578063893d20e8146100a55780639873400e146100c3578063d2255403146100f3575b5f5ffd5b610073600480360381019061006e91906105f9565b61010f565b005b61008f600480360381019061008a919061065b565b610123565b60405161009c9190610695565b60405180910390f35b6100ad610216565b6040516100ba9190610695565b60405180910390f35b6100dd60048036038101906100d8919061065b565b61024b565b6040516100ea9190610695565b60405180910390f35b61010d600480360381019061010891906106ae565b610345565b005b6101176103b5565b6101208161047d565b50565b5f5f61012d610540565b90505f73ffffffffffffffffffffffffffffffffffffffff16815f015f8561ffff1661ffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141583906101da576040517f6e0eba3b0000000000000000000000000000000000000000000000000000000081526004016101d191906106fb565b60405180910390fd5b5030836040516101e99061058e565b6101f492919061076f565b604051809103905ff08015801561020d573d5f5f3e3d5ffd5b50915050919050565b5f5f610220610567565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b5f5f610255610540565b90505f73ffffffffffffffffffffffffffffffffffffffff16815f015f8561ffff1661ffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614158390610302576040517f6e0eba3b0000000000000000000000000000000000000000000000000000000081526004016102f991906106fb565b60405180910390fd5b50805f015f8461ffff1661ffff1681526020019081526020015f205f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16915050919050565b61034d6103b5565b5f610356610540565b905081815f015f8561ffff1661ffff1681526020019081526020015f205f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505050565b5f6103be610567565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161433825f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169091610478576040517f0992ea8300000000000000000000000000000000000000000000000000000000815260040161046f929190610796565b60405180910390fd5b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614155f906104ef576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016104e69190610695565b60405180910390fd5b505f6104f9610567565b905081815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050565b5f7f433f1e912c5d27d7a45609db3e669bf6cc6b4b451297228e4c27368efb8c2300905090565b5f7fbfdc26bbaea09886fc184fe4fcae59b15cffdf4b859be87d5955dbd541465600905090565b6103f5806107be83390190565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6105c88261059f565b9050919050565b6105d8816105be565b81146105e2575f5ffd5b50565b5f813590506105f3816105cf565b92915050565b5f6020828403121561060e5761060d61059b565b5b5f61061b848285016105e5565b91505092915050565b5f61ffff82169050919050565b61063a81610624565b8114610644575f5ffd5b50565b5f8135905061065581610631565b92915050565b5f602082840312156106705761066f61059b565b5b5f61067d84828501610647565b91505092915050565b61068f816105be565b82525050565b5f6020820190506106a85f830184610686565b92915050565b5f5f604083850312156106c4576106c361059b565b5b5f6106d185828601610647565b92505060206106e2858286016105e5565b9150509250929050565b6106f581610624565b82525050565b5f60208201905061070e5f8301846106ec565b92915050565b5f819050919050565b5f61073761073261072d8461059f565b610714565b61059f565b9050919050565b5f6107488261071d565b9050919050565b5f6107598261073e565b9050919050565b6107698161074f565b82525050565b5f6040820190506107825f830185610760565b61078f60208301846106ec565b9392505050565b5f6040820190506107a95f830185610686565b6107b66020830184610686565b939250505056fe608060405234801561000f575f5ffd5b506040516103f53803806103f58339818101604052810190610031919061018a565b610041828261004860201b60201c565b50506101c8565b5f6100576100bd60201b60201c565b905082815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081815f0160146101000a81548161ffff021916908361ffff160217905550505050565b5f7f828626e98fd64181cb42e58a50c4931f9ea11da1800ee5ae64b4a2a58285ae00905090565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610111826100e8565b9050919050565b5f61012282610107565b9050919050565b61013281610118565b811461013c575f5ffd5b50565b5f8151905061014d81610129565b92915050565b5f61ffff82169050919050565b61016981610153565b8114610173575f5ffd5b50565b5f8151905061018481610160565b92915050565b5f5f604083850312156101a05761019f6100e4565b5b5f6101ad8582860161013f565b92505060206101be85828601610176565b9150509250929050565b610220806101d55f395ff3fe60806040525f61000d6100ac565b73ffffffffffffffffffffffffffffffffffffffff16639873400e6100306100e1565b6040518263ffffffff1660e01b815260040161004c9190610148565b602060405180830381865afa158015610067573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061008b91906101bf565b9050365f5f375f5f365f845af43d5f5f3e805f81146100a8573d5ff35b3d5ffd5b5f5f6100b6610105565b9050805f015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691505090565b5f5f6100eb610105565b9050805f0160149054906101000a900461ffff1691505090565b5f7f828626e98fd64181cb42e58a50c4931f9ea11da1800ee5ae64b4a2a58285ae00905090565b5f61ffff82169050919050565b6101428161012c565b82525050565b5f60208201905061015b5f830184610139565b92915050565b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61018e82610165565b9050919050565b61019e81610184565b81146101a8575f5ffd5b50565b5f815190506101b981610195565b92915050565b5f602082840312156101d4576101d3610161565b5b5f6101e1848285016101ab565b9150509291505056fea26469706673582212205ea8572b2dc4952057aa047c7aa2c5ab28dfdae8fec0a824bf2f165add8790a764736f6c634300081c0033a26469706673582212200dfbaa80ed868e9e7551a63fcf10d02f51faca90f731fe8f24ef59eb97e0e85664736f6c634300081c0033