How can I send eth on specific time?
In case the ICO crowd sale starts on 9:00:00 UTC, how can I make txid on 9:00:00 exactly when I send eth?
How can I send eth on specific time?
In case the ICO crowd sale starts on 9:00:00 UTC, how can I make txid on 9:00:00 exactly when I send eth?
You can use a double Oraclize query with a calculated delay.
This works as follows:
pragma solidity ^0.4.XXX;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract ExampleContract is usingOraclize {
uint public time;
uint public delay;
uint public desired_time; // 9:00 of desired day/month and year on UNIX time format
event LogConstructorInitiated(string nextStep);
event LogTimeUpdated(string time);
event LogNewOraclizeQuery(string description);
function ExampleContract() payable {
LogConstructorInitiated("Constructor was initiated.");
delay = 0;
updateTime();
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) revert();
time = parseInt(result,0);
LogTimeUpdated(result);
if(time < desiredtime)
delay= desiredtime - time;
updateTime();
else if(time == desiredtime || time > desiredtime){
//do what you want to do at 9:00
}
}
function updateTime() payable {
if (oraclize_getTime("URL") > this.balance) {
LogNewOraclizeQuery("Oraclize query was NOT sent, please add some
ETH to cover for the query fee");
} else {
LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer..");
oraclize_query(delay, "URL", "xml or json(parsing of the xml or json").parse.parse....;
}
}
}
Here you have info about Oraclize and how to use it: https://docs.oraclize.it/#ethereum-quick-start-the-query-id
Here you also have a site where you can make Oraclize query for the current time in UNIX format: https://timezonedb.com/api
I did the code fast maybe a quick revision is needed but with this you can get a good idea of what you can/have to do.
Hope it helps!