Created
October 27, 2025 00:44
-
-
Save Violet-Bora-Lee/e43bfdac3b76373a0767f7100b5cae4a to your computer and use it in GitHub Desktop.
하나금융-Hardhat실습
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity ^0.8.28; | |
| // Import the hardhat console | |
| import "hardhat/console.sol"; | |
| contract MyTest { | |
| uint256 public unlockTime; | |
| address payable public owner; | |
| event Widthrawal(uint256 amount, uint256 when); | |
| constructor(uint256 _unlockTime) payable { | |
| require( | |
| block.timestamp < _unlockTime, | |
| "Unlock time should be in the future" | |
| ); | |
| unlockTime = _unlockTime; | |
| owner = payable(msg.sender); | |
| } | |
| function withdraw() public { | |
| require(block.timestamp >= unlockTime, "You can't withdraw yet"); | |
| require(msg.sender == owner, "You aren't the owner"); | |
| emit Widthrawal(address(this).balance, block.timestamp); | |
| owner.transfer(address(this).balance); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment