I'm trying to run an example Solidity program - Congress from Etherum.org which I believe it should be right, but I always got "transact to Congress.addMember errored: Gas required exceeds limit: 300000000. An important gas estimation might also be the sign of a problem in the contract code. Please check loops and be sure you did not sent value to a non payable function (that's also the reason of strong gas estimation). " when I call a function in Remix while it can be called successfully from an ether wallet. The function I called is addmember(address targetMember, string memberName):
mapping (address => uint) public memberId;
Member[] public members;
struct Member {
address member;
string name;
uint memberSince;
}
function Congress (
uint minimumQuorumForProposals,
uint minutesForDebate,
int marginOfVotesForMajority
) payable public {
changeVotingRules(minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority);
// It’s necessary to add an empty first member
addMember(0, "");
// and let's add the founder, to save a step later
addMember(owner, 'founder');
}
function addMember(address targetMember, string memberName) onlyOwner public {
uint id = memberId[targetMember];
if (id == 0) {
memberId[targetMember] = members.length;
id = members.length++;
}
members[id] = Member({member: targetMember, memberSince: now, name: memberName});
MembershipChanged(targetMember, true);
}
More strange thing is if I call addmember(0x45598A0733111F1Cff340504dE74cbCDC54B101d,"Name1")
, Remix told me this gas error, but if I call addmember(0x0,"Name1")
, It can be done without any problem.
I use Injected web3 option and Ropsten testnet, and I send 0 ether as value, gas limit from 300000 to 300000000, all don't work. Any suggestion?