1

I have seen contracts use block numbers to manage when the crowdsale should start and stop. How reliable is this? I understand the average time in ethereum is 17secs between blocks, but can this be relied on as this can change in the future.

const startBlock = web3.eth.blockNumber + 2 // blockchain block number where the crowdsale will commence.

const endBlock = startBlock + 300  // 300 is little over an hour.

If this is avg 17 secs, can this be accurately use to give bonus slabs during the crowdsale? If not, what would be the best alternative?

2

Yes, of course. Both block timestamp and block number are equally reliable. There is an entire alarm clock system built in ethereum for executing something at a later stage. For more info on that you can even have a look at How can a contract run itself at a later time?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.