我创建了一个智能合约,当我使用remix调用“ deposit”功能时,效果很好,但是当我使用myetherwallet调用“ deposit”功能时,它会引发错误:“所需气体超出限额或交易始终失败”
我将此合同部署到了罗普森网络中, 合约地址:0xe09173bc458cbb421cf1e8813bedf68522839ef8
智能合约的源代码:
pragma solidity ^0.5.0;
contract Deposit{
mapping(address=>uint) private balance;
mapping(address=>bool) private hasDeposit;
event depositEvent(address addr, uint val, uint48 TeraAcc);
function deposit(uint48 TeraAccountNum) public payable{
require(msg.value>=10000000000, "Please deposit more than 10gwei!");
require(TeraAccountNum!=0, "Please input your tera account!");
balance[msg.sender] += msg.value;
hasDeposit[msg.sender]=true;
emit depositEvent(msg.sender, msg.value, TeraAccountNum);
}
function getBalance() view public returns(uint){
require(hasDeposit[msg.sender]==true, "You haven't deposit yet!");
return balance[msg.sender];
}
function getTotalBalance() view public returns(uint){
return address(this).balance;
}
function() external payable{
deposit(0);
}
}
我希望该合同在remix和myetherwallet上都可以正常工作,但是在myetherwallet中调用deposit函数时,它总是会出错,请帮忙。