I am using the following code structure;
pragma solidity ^0.5.0;
contract TtdmToken {
uint256 public totalSupply;
function TtdmToken () public {
totalSupply = 1000000;
}
}
But when compiling with truffle compile I am getting the following error,
I have seen similar issue here suggesting the change of contract name I changed the contract to the following but still getting similar results.
pragma solidity ^0.5.0;
contract TtdmToken {
uint256 public totalSupply;
function TtdmToken () public {
totalSupply = 1000000;
}
contract constructor_TtdmToken {
function TtdmToken()
}
}
And this is the error after making the change;
Best Answer
The compiler complains because
function TtdmToken()
ends unexpectedly (your second attempt).Use
constructor()
instead offunction()
(of any name) to make a constructor.Hope it helps.