2

When I input the following contract into Parity's develop field it does not complain but I also doesn't compile the contract which makes it impossible to deploy. Any suggestions? I tried linting the contract but it seems syntactically correct.

pragma solidity ^0.4.11;

/// @title Name Resolver for multiple contracts
/// Resolves contract names to their current version's address
contract Register {
    address owner;
    mapping (string => address) public backends;

    function Register() {
        owner = msg.sender;
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    function changeBackend(string contractName, address newBackend) public onlyOwner() returns (bool) {
        if(newBackend != backends[contractName]) {
            backends[contractName] = newBackend;
            return true;
        }

        return false;
    }
}
1

It turns out that it is an error that neither Parity nor atomlinter shows. Using Remix gives the error:

"Accessors for mapping with dynamically-sized keys not yet implemented.”

So the error can be fixed by changing the mapping to:

mapping (bytes32 => address) public backends;

And provide a custom getter for the backends:

function getBackend(string contractName) returns (address) {
    return backends[keccak256(contractName)];
}

Similar procedure with the setter.

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.