11

This question already has an answer here:

The warning is from running sample code from Mastering Ethereum, I get the above error and it says

Use "constructor(...) { ... }" instead. function Migrations() public {

marked as duplicate by smarx, Achala Dissanayake, flygoing, Community May 1 '18 at 15:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

14

This is because of a deprecated standard. In the file, Migrations.sol, replace the line:

function Migrations() public {    

with:

constructor() public {

The line of code shown just above is a constructor, it runs on a contract's deployment, and it is used(as in the file in context) to save the contract owner's address(msg.sender varies based on who interacts with the contract).

This replaces the existing implementation of using a function with the same name as the contract to act as a constructor with a seperate constructor function.

  • 2
    It's wrong, it's not function constructor but simply constructor. – Eli Drion Apr 30 '18 at 22:20

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