Questions tagged [timestamp]

Questions related to the timestamp value of a block, or the use of Ethereum in timestamping.

Filter by
Sorted by
Tagged with
26
votes
3answers
6k views

Can a contract safely rely on block.timestamp?

How safe is it to use block.timestamp as contract expiration time? If a miner provides an incorrect timestamp in a block header, how much can it be off before it is rejected by other nodes? Is there a ...
16
votes
3answers
3k views

How do Ethereum mining nodes maintain a time consistent with the network?

We have established that the timestamp on a parent block has to be before the timestamp of a child block in Can a child block have an earlier timestamp than the parent block?. How are differences in ...
8
votes
2answers
14k views

How to get current time by solidity?

I'd like to describe time like Apr15th 10:00AM . I know how to describe time range as follows, but I am not sure how to call date of time. Could you tell me about it if you know? 1 == 1 second 1 ...
22
votes
4answers
19k views

Is the block.timestamp value in Solidity seconds or milliseconds?

I'm looking to use block.timestamp in one of my contracts and I want to know whether the block.timestamp is seconds like in Python or milliseconds like in Java or some other value? Also, is it safe ...
13
votes
2answers
4k views

Is block.timestamp safe for longer time periods?

I would like to set a timer like uint timeout = now + 1 year; Is it possible that a miner cheats the timestamp of the block that it's included more then let's say a month. So if I need roughly 1 ...
8
votes
1answer
12k views

Solidity: Is there a way to get the timestamp of a transaction that executed?

Is there a way for a contract to be able to get the exact time someone called a function in it? For example, if someone sends funds to the contract address, is there a timestamp recorded by the ...
7
votes
2answers
522 views

Can a child block have an earlier timestamp than the parent block?

From From EIP 2, the Homestead difficulty adjustment algorithm is: block_diff = parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99) + int(2**...
17
votes
1answer
3k views

Is Solidity block.number more secure than timestamp?

In Solidity, some properties such as block.timestamp are attackable by miners and are not (strongly) protected by the protocol. How about block.number, could a miner introduce a randomly high number? ...
12
votes
3answers
13k views

How do you work with Date and time on Ethereum platform

Is there a way to access Date object in solidity like in JS? If so, wouldn't it be wrong to call solidity deterministic? So i guess if it called so, you can't. So the question is - how do you work ...
7
votes
2answers
1k views

Solidity: Timestamp dependency, is it possible to do safely?

My contract depends on checking to see if an expiration period has expired before sending the contracts balance. I was looking at the ConsenSys best practices here and it says: Timestamp Dependence ...
5
votes
3answers
1k views

How can I mock the time for solidity tests?

My contract has an expiration date that I'd like to unit test but I don't know how to go about doing that. If I could mock the time of the contract that would be dope. Google search provided no ...
2
votes
2answers
182 views

Get latest update time-stamp of contract variable

Is it possible to get latest update time of contract variable without preserving the transaction hash, contract Demo{ uint numb; function setNumb(uint var1){ numb=var1 } } in above contract ...
1
vote
2answers
1k views

How time difference can be calculated by block.number and how it is different from block.timestamp?

I have been looking into the code recently done by some developers, they are using block.number + numbers to calculate the time difference. For example if I want to lock fund for some 6 months or 180 ...
7
votes
1answer
1k views

How does Ethereum regulate the time between blocks?

I was reading "Explanation of genesis file" and I found the description of the timestamp: A scalar value equal to the reasonable output of Unix’ time() function at this block inception. This ...
2
votes
0answers
609 views

Parity - scheduled TX on local time zone

Looks like the Parity Browser doesn't show the local time zone for a "send after Date & Time' functionality. Questions: What is the time zone for a scheduled TX on Parity? If the scheduled ...
6
votes
1answer
2k views

How to avoid block.timestamp warning?

I am aware that miner can have influence on block.timestamp My question is, how to avoid this warning?
4
votes
2answers
792 views

How does time in the blockchain work?

I hope this question is not bad one, but this has been something I have been having trouble understanding. How does time in the blockchain work, and how can I utilize variables like block.timestamp ...
3
votes
1answer
925 views

How does Ethereum avoid inaccurate timestamps in blocks?

A contract can reference the currently being mined contract's timestamp. This means that changing the timestamp of an in-progress to be mined block requires executing all contracts referencing that ...
2
votes
1answer
3k views

Block time and confirmation time

I have been reading in different papers and comments these two concepts and I would like to know the difference between them(if there is, sometimes it is a bit confusing). I understand that the block ...
1
vote
1answer
169 views

Unable to schedule a call using Aion Recurring Contract

So here's the contract that I deployed on Ropsten Network. I took code refer from here. pragma solidity ^0.4.24; // interface Aion contract Aion { uint256 public serviceFee; function ...
1
vote
1answer
43 views

Are the timestamps of blocks for Ethereum only accepted when they are monotonically increasing?

Are the timestamps of blocks for Ethereum only accepted when they are monotonically increasing? If yes, why? And why other blockchains like Bitcoin and other blockchains with shorter block time can ...