Hacker News new | ask | show | jobs
by heptathorp 2909 days ago
Every Ethereum block contains a timestamp which smart contracts can read, so it's trivial to write code that only allows withdrawals in 1 month intervals.

There's no way to revoke a transaction but you could implement a hold so ETH could only be withdrawn from the contract x days after the charge is incurred, within such time the owner could cancel the withdrawal.

As far as notifications are concerned, there are events in Ethereum that you can subscribe to. So for example you could subscribe to a charge event, and go in and dispute it.

1 comments

> Every Ethereum block contains a timestamp which smart contracts can read, so it's trivial to write code that only allows withdrawals in 1 month intervals

Not disagreeing, just wanted to point out that one needs to be careful with timestamps in Ethereum, as the source of truth is miner. Using timestamps could result in security vulnerabilities.

True if you're being really fine-grained about it, like using the timestamp as the seed of a random number generator.

However, on the scale of a month, the miners aren't going to be able to mess with you. A block stamped with a significantly incorrect timestamp won't be accepted by other miners.

Are you sure about that? I was under the impression that there were no checks whatsoever and it's only a goodwill of miners (and lack of incentive to do otherwise) that provides somewhat accurate time.

On the flip side, I'm sure there are/will be oracles for approx. block time, so this is still a solveable issue.

Here's a spec from 2015:

https://github.com/ethereum/wiki/blob/c02254611f218f43cbb075...

From the block validation section: "Is block.timestamp <= now + 900 and is block.timestamp >= parent.timestamp?"

(In Solidity, block.timestamp is in seconds, and I think that's a direct translation from the underlying opcode, so I assume it's 900 seconds here.)

I stand corrected - it seems blocks' time must be increasing and must not be more than 15 minutes in the future, according to clocks of validating miners. Thanks, didn't know that!