That's copy-paste of my question on SE: http://ethereum.stackexchange.com/questions/8445/contract-with-mappingaddress-bool-does-not-work-as-expectedI have a very simple Solidity contract:
contract AccessManager {
mapping(address => bool) public registry;
function grantAccess(address assetAddr) {
registry[assetAddr] = true;
}
function isAuthorized(address assetAddr) constant returns (bool) {
return registry[assetAddr];
}
}
Logic is simple: whenever I call grantAccess(...) method an address (passed as an method argument) has to be added to mapping with "true" value.
The problem is that this simple code does not work. After I send a transaction to execute grantAccess("0x.....") method, I call isAuthorized("0x....) method and it always returns "false". I've tried it with Chrome extension called "Sol" and with .NET Etherum API. The result is always same: isAuthorized(...) contract method returns "false" no matter what I do.
Here is how I call contact methods in Sol extension:
I think the problem is in passing string as an address argument but I have another contract where I do a similar thing and it works just fine.
Did somebody experience similar issues?
Comments
Unfortunately C# API wrapper (Nethereum) continues returning wrong results.
I was able to grant access to an account throught C# code and verify that blockchain contains correct results using browser-solidity.
But as "isAuthorized" method is constant, it does not require any gas for its execution. Normally I would have to get an exception but I didn't, instead I was receiving "false" (default value) all the time.