1

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 .

2

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? – Sukhmaninder Jul 11 '16 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" – Roland Kofler Jul 11 '16 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? – Sukhmaninder Jul 11 '16 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. – Roland Kofler Jul 11 '16 at 11:34
  • Okay. How do I call the function from miner side such that the mining starts? – Sukhmaninder Jul 11 '16 at 11:36

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.