The warning is from running sample code from Mastering Ethereum, I get the above error and it says
Use "constructor(...) { ... }" instead. function Migrations() public {
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityThe warning is from running sample code from Mastering Ethereum, I get the above error and it says
Use "constructor(...) { ... }" instead. function Migrations() public {
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.
function constructor
but simply constructor
.
Apr 30, 2018 at 22:20