0

My code is here:

pragma solidity ^0.4.20;

contract Hello{

    string name;
    function Hello(){
        name = "Mike";
         }
}    

However I see this warning :

browser/Hello.sol:6:5: Warning: No visibility specified. Defaulting to "public". function Hello(){ ^ Spanning multiple lines.

1

This is because, since Solidity is a smart contract language and needs to be highly auditable, a lot of warnings/errors like this are added with the idea that explicit definitions are much better than implicit definitions. In your case, it's because functions are implicitly public if not visibility modifier is explicitly marked. Just change it to this (unless you don't want it to be public) and the warning will go away:

contract Hello {
    string name;

    function Hello() public {
        name = "Mike";
    }
}

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.