I'm trying to learn how to create tokens using Solidity/MIST.

I have modified a pre existing contract on a functioning token but I am having an error whenever I insert it into Ropsten.

The contract code can be seen here (it pasted oddly into stackexchange)


The error i'm getting is:

 No visibility specified. Defaulting to "public".
function Ownable() {
^Spanning multiple lines., 

Any help with this would be appreciated.

2 Answers 2


This is probably a duplicate but I'll leave it to others to confirm that.

The error is really a warning. It's simply saying that no visibility was specified, so it's going with the default. This has been related to security issues in contracts - evidently, developers didn't realize their sensitive functions were open to "public". This error is added to more recent compilers to turn the dev's attention to a possible risk.

You can easily silence the warning by adding the modifier public:

function Ownable() public { ...

This won't change anything about the compiled code but it will signal the compiler that you are aware of the public visibility.

Hope it helps.

  • Is it safe to leave most things as public? Commented Jan 26, 2018 at 18:03
  • I think it's safer to say that visibility should be limited to those who should see it. It just happens that the most common use-case something users and contracts are supposed to see. Public functions are the most common. The Parity debacle is traceable to a public function that (arguably) should have been guarded better because a random user was permitted to execute something that caused some damage. This warning would have said "hey ... do you realize it's public?" Commented Jan 26, 2018 at 18:39
  • Thanks for the help Rob, i'm banging my head of the wall, do you have twitter? I've a few questions you could probably answer quickly. I'm @barryflood on twitter. Commented Jan 26, 2018 at 18:46
  • I got it working! :-) Commented Jan 26, 2018 at 18:56

This happens when you are not specifying visibility of the function.

I suggest to read Solidity Documentation to understand Function Types and Visibility and Getters.

There are currently 4 function types:

  • public - can be used both as an internal and as an external function.
  • internal - can only be called inside the current contract.
  • external - can be called from other contracts and via transactions.
  • private - are only visible for the contract they are defined in and not in derived contracts.
  • Thanks for this, i've added public to most things. I'm getting another error now though: function mul(uint256 a, uint256 b) internal constant returns (uint256) { uint256 c = a * b; assert(a == 0 || c / a == b); return c; } Function state mutability can be restricted to pure function mul(uint256 a, uint256 b) internal constant returns (uint256) { ^ Spanning multiple lines. , what does that mean? Commented Jan 26, 2018 at 18:10
  • The same warning. Compiler suggests you to modify visibility of this function to pure. Just do it. Commented Jan 26, 2018 at 18:12
  • I've done this but keep running into more errors. I appreciate the help. what does this mean? Overriding function changes state mutability from "pure" to "view". function balanceOf(address _owner) public view returns (uint256 balance) { ^ Spanning multiple lines. Commented Jan 26, 2018 at 18:26
  • This one means that you need to change visibility from pure to view, because you are using external for this function variables, but not changing any stored data. Commented Jan 26, 2018 at 18:28
  • It already is set as view I think, unless i'm missing something? unction balanceOf(address _owner) public view returns (uint256 balance) Commented Jan 26, 2018 at 18:31

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.