Is there a method to wait a certain amount of seconds in idle?
I want to simulate a production process within a prototype smart contract and therefore i want to wait 5 seconds to represent this process.
Is there a method to wait a certain amount of seconds in idle?
I want to simulate a production process within a prototype smart contract and therefore i want to wait 5 seconds to represent this process.
You cannot pause the execution of a smart contract directly. If a sleep instruction was part of the protocol, it would be a huge security risk to Ethereum because it could be used to slow down miners so much that the network would become unusable.
And even if you could, you wouldn't notice it because the results of a contract execution are written into the blockchain when the block is mined. Waiting for a confirmation takes a random amount of seconds anyway. (on average about 15 seconds, which is more than your 5)
There is a way to have a function of your Solidity contract executed at a later time:
http://www.ethereum-alarm-clock.com/
But you're not going to get it to be precisely 5 seconds.
I would recommend waiting 5 seconds in the client-side code that uses your contract, instead of trying to wait 5 seconds in Solidity directly.