pragma solidity ^0.4.16;
// 对象
contract HelloWorld{
string Myname = "zifuchuan";
function getName() public view returns(string){
return Myname;
}
}
important point
- pragma solidity ^0.4.16; The definition version. In many old tutorials, the version number set is 0.4.0. This will cause a problem. An
error is reportedExpected token LBrace got ‘View‘ function getMessage()
. At first, it was a pit. After reading this blog, I jumped out of the pit. - On the right side, you need to select the correct compiled version, select >=0.4.16, and the version less than 0.5
- The reference tutorial is the most clicked development tutorial on station B: Ethereum-based smart contract development tutorial [Solidity]