I have my contract and people can buy my tokens via web3 and MetaMask. Now when I try to execute sell() function throw an exception and always Etherscan says Failed.
I set to sell and buy prices on my contract.
Here is my sell function:
/// @notice Sell `amount` tokens to contract
/// @param amount amount of tokens to be sold
function sell(uint256 amount) public {
require(address(this).balance >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, this, amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
I don't know what more I have to do. Does someone have any idea to help me?
UPDATE: Full code: https://pastebin.com/eBYC77GV.
UPDATE2: Etherscan Report: https://etherscan.io/tx/0x1213ca9540b8b7c0bd34f09dac906906772416a31e3b01559d0c0a3c05582a19
Thanks.
sellPrice
.1000000000000000 * sellPrice
being superior to the balance.