I have created a contract using Remix.

When I run the function burnFrom(), it shows:

gas required exceeds allowance or always failing transaction.

What am I doing wrong?

function burnFrom(address _from, uint256 _value) onlyOwner public returns 
(bool success) {
    require(balanceOf[_from] >= _value);                
    require(_value <= allowance[_from][msg.sender]);    
    balanceOf[_from] -= _value;                         
    allowance[_from][msg.sender] -= _value;             
    totalSupply -= _value;                              
    emit Burn(_from, _value);
    return true;
  • As the error says, the transaction always fails. You need to check that all require conditions are fullfilled. Jul 4, 2018 at 15:51

1 Answer 1


Check that you are either using the javascript VM or that you have metamask unlocked and connected to a test net if using injected web3.

Make sure you have an allowance mapping that looks like this:

mapping(address => mapping(address => uint256)) public allowance;

And that your Burn event looks like this:

event Burn(address indexed from, uint256 value);

If you have both of these correct there is probably something wrong with the onlyOwner modifier.

  • OP must have declared these mappings else he would be getting compile time error in remix. The code compiled successfully means there is no cases that he missed declarations. Jul 5, 2018 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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