I am trying to create an ERC20 token off of ethereum, but when I put the code in the editor in the ethereum wallet, I get a weird error. It says:

 "throw" is deprecated in favour of "revert()", "require()" and "assert()".
    if (balanceOf[msg.sender] < _value) throw;

(from Ethereum Blog) (Source Code) Can someone please help me with this?


As the error message states clearly

throw has been deprecated


require( balanceOf[msg.sender] >= _value)

You can find a detailed description in this article.

revert() and require() both refund any left over gas however assert() consumes all the gas provided.

The require function should be used to ensure valid conditions, such as inputs, or contract state variables are met, or to validate return values from calls to external contracts. If used properly, analysis tools can evaluate your contract to identify the conditions and function calls which will reach a failing assert. Properly functioning code should never reach a failing assert statement; if this happens there is a bug in your contract which you should fix


| improve this answer | |

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