5

I have this method on a contract that I'm testing on rinkeby

function addMatch(string _name, uint _fixtureId, uint8 _home, uint8 away, uint _start) public onlyOwner returns (uint8) {
    require(_home < NUM_TEAMS && _away < NUM_TEAMS && _home != _away);
    require(_start >= now);
    Match memory newMatch = Match({
        home: _home,
        away: _away, 
        fixtureId: uint2str(_fixtureId),
        winner: 0, 
        start: _start, 
        name: _name
    });
    uint8 matchId = uint8(matches.push(newMatch));
    string memory url = strConcat(
        "json(https://api.basketball-matches.org/[my api key]/", 
        newMatch.fixtureId,
        ").[?(@.status=='FINISHED')].result[scoreHome,scoreAway]");
    bytes32 oraclizeId = oraclize_query(_start + QUERY_INTERVAL, "URL", url);
    oraclizeIds[oraclizeId] = matchId;
    emit MatchCreated(matchId);
    return matchId;
}

No matter how much I set the gas limit to the transaction still fails, however the gasUsed displayed on ether scan is less than the gasLimit (which I set to the limit of the network). Does anyone have any idea what the issue might be. I'm using web3 and using infura through the truffle HDWallet provide.

enter image description here

Attempting to estimate the gas cost using web3 just throws an error. The error returned when I call this method on the blockchain is:

Error: Transaction ran out of gas. Please provide more gas:
4
  • Could be that one of your require-clauses interrupt the transaction
    – gisdev_p
    May 12, 2018 at 6:15
  • @gisdev_p seems it was, forgot about timezones, but why throw an out of gas error, does require consume all remaining gas? Also, mind making your comment an answer so I can give you the rep May 12, 2018 at 6:23
  • It should not consume all gas, and I don't think that it does . At least in the screenshot of your question the gas used is different and much smaller than the max gas
    – gisdev_p
    May 12, 2018 at 6:30
  • Odd error to return in such a case then, but thanks for your help May 12, 2018 at 6:33

1 Answer 1

2

Check the parameters of your function call, it looks like one of your require-clauses interrupt the transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.