Gate Layer is live! View your transactions on  Gate Layer Explorer .
gate
GT Price:$10.85-1.45%
Med Gas Fee:12.07 NANOGT
Account Details
Contract0xc2f38e84c1dc77cd10364e6a7957251d29e60dc9

Overview

GT Balance

0 GT($0)

Token Holdings

0 Tokens

More Info

Contract Creator

Contract Source Code Verified (Exact Match)
Contract Name
Storage
Optimization

Yes, with

200

runs

Compiler
solidity
Compiler Version
v0.8.20+commit.a1b79de6.js
Other Settings

istanbul

evmVersion

MIT

License

</> Contract source code
File 1 of 2: 1_Storage.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

// 导入 Owner 合约
import "2_Owner.sol"; // 路径需与 Remix 中的文件结构一致

/**
 * @title Storage
 * @dev Store & retrieve value in a variable
 * @custom:dev-run-script ./scripts/deploy_with_ethers.ts
 */
contract Storage {

    uint256 number;
    Owner private ownerContract; // 声明 Owner 合约实例

    // 构造函数:初始化 Owner 合约
    constructor(address ownerContractAddress) {
        ownerContract = Owner(ownerContractAddress); // 传入已部署的 Owner 合约地址
    }
    
    /**
     * @dev Store value in variable
     * @param num value to store
     */
    function store(uint256 num) public {
        number = num;
    }

    function store2(uint256 num) public {
        number = num;
    }
        function store3(uint256 num) public {
        number = num;
    }
    /**
     * @dev Return value 
     * @return value of 'number'
     */
    function retrieve1() public view returns (uint256){
        return number;
    }
        function retrieve2() public view returns (uint256){
        return number;
    }

        function retrieve3() public view returns (uint256){
        return number;
    }
}
File 2 of 2: 2_Owner.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

// import "hardhat/console.sol";

/**
 * @title Owner
 * @dev Set & change owner
 */
contract Owner {

    address private owner;

    // event for EVM logging
    event OwnerSet(address indexed oldOwner, address indexed newOwner);

    // modifier to check if caller is owner
    modifier isOwner() {
        // If the first argument of 'require' evaluates to 'false', execution terminates and all
        // changes to the state and to Ether balances are reverted.
        // This used to consume all gas in old EVM versions, but not anymore.
        // It is often a good idea to use 'require' to check if functions are called correctly.
        // As a second argument, you can also provide an explanation about what went wrong.
        require(msg.sender == owner, "Caller is not owner");
        _;
    }

    /**
     * @dev Set contract deployer as owner
     */
    constructor() {
        //console.log("Owner contract deployed by:", msg.sender);
        owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
        emit OwnerSet(address(0), owner);
    }

    /**
     * @dev Change owner
     * @param newOwner address of new owner
     */
    function changeOwner(address newOwner) public isOwner {
        require(newOwner != address(0), "New owner should not be the zero address");
        emit OwnerSet(owner, newOwner);
        owner = newOwner;
    }

    /**
     * @dev Return owner address 
     * @return address of owner
     */
    function getOwner() external view returns (address) {
        return owner;
    }
}
</> Contract Creation Bytecode
0x608060405234801561001057600080fd5b5060405161016638038061016683398101604081905261002f91610054565b600180546001600160a01b0319166001600160a01b0392909216919091179055610084565b60006020828403121561006657600080fd5b81516001600160a01b038116811461007d57600080fd5b9392505050565b60d4806100926000396000f3fe6080604052348015600f57600080fd5b5060043610605a5760003560e01c80632711432d14605f57806327f151f51460745780634b7bec6214605f5780636057361d146074578063ae2e2cce14605f578063ef1f1973146074575b600080fd5b60005460405190815260200160405180910390f35b6084607f3660046086565b600055565b005b600060208284031215609757600080fd5b503591905056fea2646970667358221220274bf6263c6891b250eb83c1a4f78d20329da249b983d0d078741bd8d8add1de64736f6c63430008140033000000000000000000000000a69695507b97b146c2b6b67bb97886229c0dae1b
</> Contract ABI
[{"inputs":[{"internalType":"address","name":"ownerContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"retrieve1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"retrieve2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"retrieve3","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"store2","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"store3","outputs":[],"stateMutability":"nonpayable","type":"function"}]
</> Contract Deployment Bytecode
0x6080604052348015600f57600080fd5b5060043610605a5760003560e01c80632711432d14605f57806327f151f51460745780634b7bec6214605f5780636057361d146074578063ae2e2cce14605f578063ef1f1973146074575b600080fd5b60005460405190815260200160405180910390f35b6084607f3660046086565b600055565b005b600060208284031215609757600080fd5b503591905056fea2646970667358221220274bf6263c6891b250eb83c1a4f78d20329da249b983d0d078741bd8d8add1de64736f6c63430008140033
</> Constructor arguments
000000000000000000000000A69695507b97B146c2b6b67bB97886229c0daE1b
logo
GateScan is a Block Explorer and Analytics Platform for GateChain