I am creating a cryptocurrency contract, which rewards the miner a proof of work generated. To get the reward you will need to call proofOfWork(uint nonce). If the nonce is correct, the miner is awarded.

I am calling this function at the end of each function, and planning to generate a random nonce which is passed as an argument for the function call. If the nonce is correct transaction is carried out and miner awarded. Else the execution is thrown.

How do I generate this random nonce? And is it the way you carry out proof of work? If not then, how do I use this function?

I am following the guide https://www.ethereum.org/token#proof-of-work .


1 Answer 1


The idea of the nounce is that you as a miner try to guess the correct number and therefore you can include any value you like.
There is no way of guessing the right nounce, and the work the miner has to do is that of guessing the right nounce. It's like a lottery. You include a random parameter in your transaction and try to win the mining fee.

  • Then how do I implement the function in the link? Jul 11, 2016 at 11:11
  • you should not call this function at the end of every function. It was intended to be externally called by your "miners" Jul 11, 2016 at 11:18
  • By doing this miners will be awarded for the 'mining' which gives no advantage to my contract. Why would I need such a function? If I would have wanted to give it for free, I could just program a simple transfer function. Why the 'guide' wants to waste the computation power of miner? Jul 11, 2016 at 11:30
  • you want to distribute your coins in a random way, with a simple transfer function, first comes is first served and the entire token economy will tank. Jul 11, 2016 at 11:34
  • Okay. How do I call the function from miner side such that the mining starts? Jul 11, 2016 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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