0

I am trying to update a mapping of the owner's token count when the owner burns a token.

mapping (address => uint) public ownerTokenCount; //# of tokens in wallet

It gets updated here:


_mintToken(owner) {

userTokenCount(owner) = userTokenCount(owner) + 1

_mint;

}

It should update again here but it is not.


_burntoken(owner){

(require userTokenCount(owner) >0); // this throws

userTokenCount(owner) = userTokenCount(owner) - 1;

_burn;

}

2
  • Show the full text of the smart contract and explain what exactly is not working. What you have shown does not match the Solidity syntax
    – Mad Jackal
    Commented Nov 14, 2021 at 7:20
  • Hi DabblinDantheDino! Please include a minimal compilable example that causes the problem. It is likely the error is in another part of the code.
    – Ismael
    Commented Nov 14, 2021 at 23:03

1 Answer 1

0

To access a map you need to use []

For example:

function _burntoken(address owner) private {

    require (userTokenCount[owner] > 0);

    userTokenCount[owner] = userTokenCount[owner] - 1;

    _burn();

}

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.