0

**I am Using Solidity compiler 0.4.11 When I compile my code i get the error that is " Error: Type "mapping(string => string)" not supported for state variable.\n\tmapping (string => string) dataLink **.

My code is ....

    pragma solidity ^0.4.11;

contract HDataAccessManager {

    mapping (string => string) dataLink;
    mapping (string => string) dataHash;
    mapping (string => bytes32) private passwords; 
    string[] users;


    function _isValid(string _user_id, string _encryption_key_hash) returns (bool) {
        for(uint i = 0;i<users.length;i++){
            if(keccak256(users[i]) == keccak256(_user_id) && 
                keccak256(_encryption_key_hash) == passwords[_user_id]) {

                return true;
            }
        }
        return false;
    }

    function addUser(string _user_id, string _encryption_key_hash) {
        users.push(_user_id);
        passwords[_user_id] = keccak256(_encryption_key_hash);
    }

    function totalUsers() returns (uint) {
        return users.length;
    }


    // link is alias of generated_id
    function storeLink(string _user_id, string _link){

        // check if user is present in blockchain
        //require(_isValid(_user_id, _encryption_key_hash));

        dataLink[_user_id] = _link;
    }

    function storeHash(string _user_id, string _hash){

        // check if user is present in blockchain
        //require(_isValid(_user_id, _encryption_key_hash));

        dataHash[_user_id] = _hash;
    }


    function retrieveLink(string _user_id, string _encryption_key_hash) returns (string, string) {

        //check if user is present in blockchain
        require(_isValid(_user_id, _encryption_key_hash));

        string link = dataLink[_user_id];
        string hash = dataHash[_user_id];
        return (link, hash);

}

}
0

Using version:0.4.11+commit.68ef5810.Emscripten.clang or superior this code compiles well. Note that you are using a very old version of solidity, using Remix has the advantage of giving you the latest releases of solidity.

Hope this helps

  • if the code is write why giving the error .. new version also the same problem – ashish kumar Mar 11 at 13:11
  • when using new version 0.5.0 gives this error "{"errors":[{"component":"general","formattedMessage":"* Line 1, Column 1\\n Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n Extra non-whitespace after JSON value.\\n","message":"* Line 1, Column 1\\n Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n Extra non-whitespace after JSON value.\\n","severity":"error","type":"JSONError"}]}' " – ashish kumar Mar 11 at 14:49
  • where are you compiling this? I just copied the code to remix and it worked with described above, let me know – Jaime Mar 11 at 16:29
  • i am compiling this on terminal like this " $ node > code = fs.readFileSync('HealthcareContract.sol').toString() > solc = require('solc') >compiledCode = solc.compile(code) " then getting the error – ashish kumar Mar 12 at 6:20
  • i install the compiler off solidity in terminal by "sudo npm install solidity@0.4.11" can you please check this on terminal – ashish kumar Mar 12 at 6:57

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.