3

Why does warning appear with inheritance of constructor?

contract MyToken is ERC721Token{
function MyToken(string _name, string _symbol) ERC721Token(_name, _symbol) public {
}

The content of the warning is

zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol:38:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. function ERC721Token(string _name, string _symbol) public { ^ (Relevant source part starts here and spans across multiple lines). ,/C/twork/702_Ethereum/ERC-OPZ/myERC721/contracts/MyToken.sol:8:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead. function MyToken(string _name, string _symbol) ERC721Token(_name, _symbol) public { ^ (Relevant source part starts here and spans across multiple lines).

I am using truffle v4.1.7 solidity v0.4.23

Thanking you in advance

Achala Dissanayake
  • 5,819
  • 15
  • 28
  • 38
funa
  • 43
  • 4

1 Answers1

6

Since the version 0.4.22 of Solidity, you don't define the constructor as the function with the same name than the contract, you have to use constructor(myparams....) {...} from now on.

Read more here.

Elisha Drion
  • 2,641
  • 9
  • 16