Skip to content

Commit

Permalink
ecoBurning allowance added. Burning is useful when migrating to the n…
Browse files Browse the repository at this point in the history
…ew blockchain or to decrease the supply which sort of can affect the demand (increase it). TransferFrom unlimited allowance exploit fixed
  • Loading branch information
salemalem committed Jul 23, 2021
1 parent 5c892d7 commit f812747
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions trc20token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ contract TRC20 {
return true;
}

// 3rd party can spend someone's fund if that person approved it using approve function
// spend 3rd party's approved token amount
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
require(allowance[_from][msg.sender] >= _value);
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);

return true;
}

// approve 3rd party to spend your tokens
// approve 3rd party to spend/ecoburn your tokens
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
Expand All @@ -69,4 +71,18 @@ contract TRC20 {

return true;
}

// eco burn tokens of 3rd party
function ecoburnFrom(address _from, uint256 _value) public returns (bool success) {
require(balanceOf[_from] >= _value);
require(allowance[_from][msg.sender] >= _value);

balanceOf[_from] -= _value;
allowance[_from][msg.sender] -= _value;
totalSupply -= _value;

emit EcoBurn(_from, _value);

return true;
}
}

0 comments on commit f812747

Please sign in to comment.