Foundry 工具链分享

  • bixia1994
  • 更新于 2022-03-26 23:01
  • 阅读 2893

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

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{}
}
点赞 2
收藏 5
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

6 条评论

请先 登录 后评论
bixia1994
bixia1994
0x92Fb...C666
learn to code