0

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?

marked as duplicate by Jesse Busman, Achala Dissanayake, Richard Horrocks, shane, flygoing Dec 10 '18 at 19:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

As the error message states clearly

throw has been deprecated

Use

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

.

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