Answer the question
In order to leave comments, you need to log in
Token destruction, please explain?
I can't figure out how this code works?
Do I understand correctly that if the user himself wants to burn tokens, then burnFrom is called?
And in what case burn?
function burn(uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
balanceOf[msg.sender] -= _value; // Subtract from the sender
totalSupply -= _value; // Updates totalSupply
emit Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowance[_from][msg.sender]); // Check allowance
balanceOf[_from] -= _value; // Subtract from the targeted balance
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
totalSupply -= _value; // Update totalSupply
emit Burn(_from, _value);
return true;
}
Answer the question
In order to leave comments, you need to log in
As far as I understand.
burn - burn your tokens. msg.sender
burnFrom - to burn tokens of a specific address address _from
, in all likelihood, only the owner of the contract can call these methods.
this is from the ERC-20 contract.
https://github.com/ethereum/ethereum-org/blob/mast...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question