0

No matter how much gas i provide this one function it failsas it runs out of gas, i have used a tool to check how much gas it is using and it is not overly high compared to other functions. I cant see the problem in the cde at all. I have even tried re ordering functions but no luck. The function is below someone please help me its one of the last things i need sorted . Thanks in advance.

function revokeAffiliate(address _addr) public onlyOwner returns(bool) {
    require(isAffiliate[_addr]);
    isAffiliate[_addr] = false;
    affiliateCodeToAddr[affiliateCodeOfAddr[_addr]] = address(0);
    emit AffiliatePartnershipRevoked(_addr, affiliateCodeOfAddr[_addr]);
    affiliateCodeOfAddr[_addr] = "No longer an affiliate partner";
    return true;
}
3
  • I have tried giving it more gas over and over in remix vm, i have tried using a tool to see the gas usage and match that then up it and still failing its making no sense to me Commented Apr 15, 2022 at 16:24
  • Looks like we ran into the same problem. ethereum.stackexchange.com/questions/126292/… I think this is a remix bug? Commented Apr 15, 2022 at 17:46
  • @destructioneth i managed to sort mine it was due to a code error good luck with yours Commented Apr 15, 2022 at 18:29

1 Answer 1

0

I think the gas is high because you are trying

affiliateCodeToAddr[affiliateCodeOfAddr[_addr]] = address(0). As, affiliateCodeToAddr mapping seems to have string as it's key.

Try to encode the string to bytes through abi.encode. Or, use some sort of indexes for each key. Like 0 could represent "No longer an affiliate partner", 1 could represent something arbitary, and so on.

1
  • Ye i managed to work that out aswell was a simple order error. Thanks for confirming this tho. Commented Apr 15, 2022 at 18:29

Your Answer

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

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