Linked Questions

3
votes
1answer
173 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 ...
195
votes
20answers
68k views

How can I securely generate a random number in my smart contract?

If I am writing a smart contract for some kind of (gambling) game, how can I generate a random number securely? What are the best practises and security trade-offs to be aware of?
3
votes
2answers
469 views

How to hide transactions from mempool?

I am testing out blocknative's mempool explorer (https://explorer.blocknative.com) and noticed a lot of pending transactions are actually already confirmed by the time it picks them up, which I can ...
15
votes
3answers
7k views

what is block.timestamp

In a function, does block.timestamp record the time the transaction was processed, or the time the block.timestamp computational step was processed? Is block.timestamp the time the transaction is ...
30
votes
1answer
5k views

When can BLOCKHASH be safely used for a random number? When would it be unsafe?

I've seen more complicated ways for a contract to generate a random number. But the Ethereum Yellow Paper itself suggests a "trivial solution" using the BLOCKHASH opcode (see below, bold is mine). ...
40
votes
4answers
43k 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 ...
15
votes
2answers
28k 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 ...
1
vote
1answer
583 views

Get time when the transaction was included in your node

Is there any way to obtain the time when you have received a transaction? I would like to know when is a Smart contract included in my node. (local testnet)
0
votes
0answers
79 views

SmartContract determine timestamp of saving data

I have really simple solidity smartcontract for saving and fetching data structs. When I ask for data struct (fetching function) I need to know timestamp (or block ID) when was the struct saved. How ...
5
votes
2answers
943 views

Check that the timestamp of the block is greater than that of the previous block and less than 2 hours into the future?

I am reading the White Paper of Ethereum. And at the Mining Section, I do not understand the this part "less than 2 hours into the future" of the following sentence: Check that the timestamp of the ...
2
votes
0answers
543 views

Working with time in smart contracts

I know there have been quite a few questions surrounding time, and the use of block.timestamp. However, I still have a few questions design-wise. At what point exactly is it 'dangerous' to use block....
0
votes
1answer
228 views

How are price changes based on time implemented in crowdsale smart contracts?

How can I implement a price structure into a crowdsale smart contract so that a price per token would be increased after a certain time? I want to use best practices for this but cannot find ...
0
votes
2answers
58 views

Are there other sources of input to a contract than transaction data or the invocation of other contracts?

Are there other sources of input to a contract than transaction data or the invocation of other contracts? I've wondered whether there are other sources of input to a contract than those mentioned ...
17
votes
2answers
2k views

How would a miner cope with a huge block time?

Given that: According to the white and yellow paper a block's timestamp must be bigger than the parent's. According to the white paper a block's timestamp can be within 15 min of the parent ...
3
votes
2answers
163 views

Are there any misbehaving miners?

Many of the discussions I read about security relate to how miners can manipulate this or that aspect of the way a transaction gets processed, such as whether or not it's included, what it's timestamp ...

15 30 50 per page