I'm trying to make a function that uses unix timestamp for setting a limited time and after the limited time is over I would like to make clients get their token by themselves Does anyone have any idea or help? Thanks!
Asked
Active
Viewed 139 times
1 Answers
0
Here's a small example on how it could work:
pragma solidity ^0.4.24;
contract TimedTokenVault {
uint256 startTime;
function setStartTime(uint256 _startTime) public {
// add access restrictions and/or make sure this can be called only once
startTime = _startTime;
}
// Clients can call this after the startTime
function requestToken() public {
require(startTime > now, "Sorry, token requests is not open yet");
// transfer token(s)
}
}
The example is missing a lot of required code but you should get the idea. After checking the startTime in requestToken you can probably use regular token transfer method to transfer the tokens.
Lauri Peltonen
- 29,391
- 3
- 20
- 57