1

Using Solidity 0.4.17, I have defined a simple library at ./StringUtils.sol

library StringUtils {
    function isEmptyString(string s) external pure returns (bool) {
        return (keccak256(s) == keccak256(''));
    }
}

Now I am trying to use it in a contract at ./PastryChef.sol

import './StringUtils.sol';


contract PastryChef {
    using StringUtils for StringUtils;

    string name;

    function PastryChef(string _name) public {
        require(!StringUtils.isEmptyString(_name)); // name must not be empty
        name = _name;
    }

}

I get the error

TypeError: Member "isEmptyString" not found or not visible after argument-dependent lookup in type(library StringUtils)
        require(!StringUtils.isEmptyString(_name)); // name must not be empty
                 ^-----------------------^

What am I doing wrong?

1 Answer 1

1

I've worked this out. The Library function can not be external but must be either internal or public.

So changing external to internal fixes it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.