3

I encouter little problems using mix. I have the following contract-code:

contract C {
    function C() {}

    struct S {
        address creator;
    }

    mapping(string => S) M;
    uint x;

    function set(string _hash) {
        S memory N = S({
            creator : msg.sender
        });

        M[_hash] = N; //I dont see the mapping in Mix
        x = _hash; //I see 'x' in the current state with the correct value
    }

    function get(string _hash) returns (address addr) {
        return M[_hash].creator;
    }
}

The problem is that I do not see the current state of the contract in the bottom right corner of the IDE. While I see x and the value of _hash, I do not see the state of the mapping(string => S), which should be in the variable M

I thought the mapping maybe is just empty after calling, but when I call the get-function, It returns the correct address from the sender before.

Does anyone had the same issue before or can help me with this?

1

Mappings work by hashing the key to get the storage address and so the keys themselves aren't stored. Unless keys can be provided, such as in a seperate lookup table, there is no simple way to view the contents of a mapping so Mix simply doesn't show them.

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.