Created
March 8, 2022 16:33
-
-
Save Aboudjem/55899f342d5d11eda68bd0a8071f2082 to your computer and use it in GitHub Desktop.
FatherSonContract
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.12; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC20/IERC20.sol"; | |
contract TestContract { | |
address mySonAddress; | |
uint amountToSend; | |
uint expirationDate; | |
address USDTContractAddress = 0xa16094F42297156809a22A7af5EbA0a1771446C9; | |
constructor(address _mySonAddress, uint _amountToSend, uint durationInYears) { | |
mySonAddress = _mySonAddress; | |
amountToSend = _amountToSend; | |
// 60sec*60 == 1min*60 == 1hour -- 1hour * 24 == 1day -- 1day * 365 == 1 year | |
expirationDate = block.timestamp + (60*60*24*365*durationInYears); | |
} | |
function withdraw() external { | |
require(block.timestamp >= expirationDate, "Expiration date not reached yet"); | |
require(msg.sender == mySonAddress, "Only son's address can call this function"); | |
IERC20(USDTContractAddress).transfer(mySonAddress, amountToSend); | |
} | |
function getMySonAddress() external view returns(address) { | |
return mySonAddress; | |
} | |
function getTimeRemaining() external view returns(uint) { | |
return expirationDate - block.timestamp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment