0
    struct allowanceInfo {
     address allowedAddress;
     bool isAllowed;
     }

    mapping(address => allowanceInfo) public allowed;

    function allow() public { 
        require(msg.sender == allowanceInfo[allowedAddress].allowedAddress);
        allowanceInfo[allowedAddress].isAllowed == true;
        }

Why is my mapping not updating the boolean value of my isAllowed variable, when I look up the allowedAddress in the mapping?

  • allowanceInfo[allowedAddress].allowedAddress raises an eyebrow... – goodvibration May 5 '18 at 13:25
  • I'm not sure why. – NowsyMe May 5 '18 at 13:29
  • Well, it won't compile to begin with (allowedAddress is not defined). – goodvibration May 5 '18 at 13:42
  • Sounds like all you need is mapping(address => bool) public allowed and require(allowed[msg.sender]), but I'm probably missing some context (which you did not bother to specify in your question). – goodvibration May 5 '18 at 13:44
0

I see a potential syntax/logic mistake. Intuitively you might try something like (even if it isn't very clear):

  struct allowanceInfo {
     address allowedAddress;
     bool isAllowed;
 }

 mapping(address => allowanceInfo) public allowed;
 modifier onlyAllowedAddress(require(msg.sender == allowed[msg.sender].allowedAddress); _;)

 function allow() public onlyAllowedAddress() { 
     allowed[msg.sender].isAllowed = true;
 }

to get a mapping value I had to specify its name "allowed" and an address between brackets in order to get the relative "allowanceInfo" struct

0

Is not clear what you are trying to do here, you are treating the structure as a mapping. Is the function suppose to check if the msg.sender is allowed? if so, then:

mapping(address => bool) public allowed;
function allow() public returns(bool){`
    return allowed[msg.sender];
}`

Hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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