Foundry 工具链分享

以太坊智能合约开发工具链

Solidity.png

//SPDX-License-Identifier: MIT

pragma solidity 0.8.12;

contract Dev {
    address public owner;
    uint256 private key;
    constructor() payable {
        owner = address(0xdeadbeef);
        key = 32;
    }
    modifier onlyOwner() {
        require(msg.sender == owner,"!owner");
        _;
    }
    function setKey(uint256 _key) public onlyOwner {
        key = _key;
    }
    function getOwner() public view returns (address) {
        return owner;
    }
    function hack(uint256 _key) public {
        require(key == _key, "Wrong key");
        payable(address(msg.sender)).transfer(address(this).balance);
    }
    receive() external payable{}
}

  • 发表于 2022-03-26 23:01
  • 阅读 ( 714 )
  • 学分 ( 3 )
  • 分类:Solidity

6 条评论

请先 登录 后评论
bixia1994
bixia1994

互联网小工

48 篇文章, 538 学分