1

I have created a smart contract to issue an ERC20 token, but when I try to send the token from one address to another I get a "Warning! Error encountered during contract execution [Bad instruction]" message on etherscan.io. The token is already created and the contract is validated.

Also, I´m able to send tokens from the address holding the tokens but once I try to send from a receiver address, I get the error.

You can see the failed transactions here.

1 Answer 1

1

Your contract has a bug

/* Internal transfer, only can be called by this contract */ function _transfer(address _from, address _to, uint _value) internal { require (_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead require (balanceOf[_from] > _value); // Check if the sender has enough require (balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient Transfer(_from, _to, _value); } 

It will not allow to transfer the full amount of tokens, it has to be strictly less. Instead of 12000, try 11999.

You have to modify your contract to

require (balanceOf[_from] >= _value); 
2
  • And is it possible to modify the contract itself, or I have to create a new one? Commented Oct 14, 2017 at 1:14
  • 1
    @Jabaco it is not possible to directly modify the source code of smart contracts. You have to deploy a new one. Commented Oct 14, 2017 at 1:38

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.