What does this warning actually mean and how to resolve this ?

enter image description here

  • Can you also upload the code and which solidity version you are using? May 7 at 10:06

This is saying that adding public - a visibility specifier - to a constructor has no effect.

Constructors are run only once, when the contract is initially deployed. They can't be called at a later time, so aren't "visible" in the sense that variables or functions are.

Abstract contracts don't have a constructor, so the error is basically saying: "You've incorrectly used a visibility specifier on a constructor - did you even mean to use a constructor in the first place, or did you intend to write an abstract contract?".

  • Oh okay so basically constructors can't have any 'visibility specifier' May 7 at 10:26
  • That's correct - there's no need for them to have one. May 7 at 11:24

In v0.5.0 it was mandatory to add visibility to the constructor. This is from the docs of the breaking changes in v0.5.0: https://docs.soliditylang.org/en/v0.7.0/050-breaking-changes.html#explicitness-requirements

Explicit function visibility is now mandatory. Add public to every function and constructor, and external to every fallback or interface function that does not specify its visibility already

I guess it wasn't mandatory before but best practice.

Things have changed since v0.7.0: https://docs.soliditylang.org/en/v0.7.0/070-breaking-changes.html#functions-and-events

Visibility (public / external) is not needed for constructors anymore: To prevent a contract from being created, it can be marked abstract. This makes the visibility concept for constructors obsolete.


remove public from constructor, that's all.

eg.- constructor( . . . ) { . . . }


its constructor, not a function. So solidity compiler says : "u don't need to make constructor public, its constructor to run one time, not a function to be made public and call again and again"


Encountered same issue with > 0.7.0. Remove the public identifier.

Like this:

constructor (string memory message) {
    requestor = msg.sender;
    requestMessage = message;

Constructors are run once, so the identifier has no effect.

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.