From f1af82b3a1fe627fd67987055c2d99868fc434bc Mon Sep 17 00:00:00 2001 From: KOSASIH Date: Mon, 2 Dec 2024 13:20:30 +0700 Subject: [PATCH] Create TimeLockedWallet.sol --- .../smart_contracts/TimeLockedWallet.sol | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 blockchain_development_integration/pi_network/smart_contracts/TimeLockedWallet.sol diff --git a/blockchain_development_integration/pi_network/smart_contracts/TimeLockedWallet.sol b/blockchain_development_integration/pi_network/smart_contracts/TimeLockedWallet.sol new file mode 100644 index 000000000..3b6b70da7 --- /dev/null +++ b/blockchain_development_integration/pi_network/smart_contracts/TimeLockedWallet.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract TimeLockedWallet { + address public owner; + uint256 public unlockTime; + + constructor(uint256 _lockDuration) { + owner = msg.sender; + unlockTime = block.timestamp + _lockDuration; + } + + function deposit() external payable { + require(msg.value > 0, "Must send Ether"); + } + + function withdraw() external { + require(msg.sender == owner, "Not the owner"); + require(block.timestamp >= unlockTime, "Funds are locked"); + + payable(owner).transfer(address(this).balance); + } + + function getLockedFunds() external view returns (uint256) { + return address(this).balance; + } +}