问题描述
pragma solidity >=0.5.1 <0.6.0;
contract HelloWorld {
mapping(address => uint) public balance;
uint public countOfInvestors = 0;
mapping(address => uint) public time;
event Invest(address investor,uint256 amount);
function deposit() private {
if (msg.value > 0) {
if (balance[msg.sender] == 0) {
countOfInvestors += 1;
}
balance[msg.sender] = msg.value;
time[msg.sender] = Now;
emit Invest(msg.sender,msg.value);
}
}
function() external payable {
deposit();
}
}
当我在合约上发送一些 TRX 时,我在 tronscan 上没有新数据,合约余额增加但不显示任何交易 如果我需要,如何签订合同? 没有一个事件和交易,但我发送了几次
解决方法
回退函数最多只能使用 2300 个 gas,而您的 deposit
函数 100% 使用的比这更多。
由于使用了过多的gas,回退函数不会被调用。