0

I'm having an issue where a method that seems straightforward is showing a huge amount of gas requirements. I tried to run it from the verified polygonscan UI and metamask tells me it can't estimate the gas (which I take to mean it's incredibly high). I can't understand, though, what it could be?

Here is some of the code in question:

mapping(address => bool) private players;
uint256 public playerCount;
event PlayerRegistered(address player);

function register(address _player) public onlyOwner {
   require(players[_player] != true, "Player already registered");
   players[_player] = true;
   playerCount += 1;
   emit PlayerRegistered(_player);
}

I must be missing something huge about mappings or public variables, otherwise this seems so straightforward.

Any ideas are greatly appreciated, thank you!!

2
  • 1
    It is working fine on my end. The code looks fine. Jul 8, 2022 at 6:18
  • 1
    Seems an issue with the way I was calling it, perhaps. Thanks for looking.
    – mcw
    Jul 8, 2022 at 14:22

1 Answer 1

0

Seems like the issue was actually the way I was calling the function, and the gas question was more of an estimation red herring.

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.