12

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

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

0

1 Answer 1

16

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.

1
  • 2
    It's wrong, it's not function constructor but simply constructor. Apr 30, 2018 at 22:20

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