我有我的合同,人们可以通过 web3 和 MetaMask 购买我的代币。现在,当我尝试执行 sell() 函数时会抛出异常,并且 Etherscan 总是说失败。
我开始按照我的合同买卖价格。
这是我的销售功能:
/// @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
}
我不知道我还需要做什么。有人有什么想法可以帮助我吗?
更新:完整代码:https ://pastebin.com/eBYC77GV 。
UPDATE2:Etherscan 报告:https ://etherscan.io/tx/0x1213ca9540b8b7c0bd34f09dac906906772416a31e3b01559d0c0a3c05582a19
谢谢。