1

I would like a simple address book referencing a user name to an ethereum address like,

mapping (string => address) addressOf;

Unfortunately I can't access that mapping as a public call, as strings are dynamically-sized.

Is there any existing solution or work around, to access a string key mapping without .sendTransaction?

2

You can use bytes32 like this:

contract NameRegistry {
    mapping(bytes32 => address) addressBook;

    function set(string a, address b){
        addressBook[sha3(a)] = b;
    }

    function get(string a) constant returns(address){
        return addressBook[sha3(a)];
    }
}

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.