# solidity 基础语法学习 **Published by:** [阿拉斯加的狗](https://paragraph.com/@arych/) **Published on:** 2022-02-13 **URL:** https://paragraph.com/@arych/solidity ## Content pragma solidity ^0.4.16; contract helloworld { string Myname = "Test"; function getName() public view returns(string) { return Myname; } function changeName(string _newName) public { Myname = _newName; } function pureTest(string _name) public pure returns(string) { return _name; } } `view / pure 的区别 view的作用和constant一模一样,可以读取状态变量但是不能改;pure则更为严格,pure修饰的函数不能改也不能读状态变量,否则编译通不过。 solidity的语法结束语句都以"' ; " 结束 contract 后面跟上的合约可以理解为一个class 函数都需要有状态表明 比如" public;` ## Publication Information - [阿拉斯加的狗](https://paragraph.com/@arych/): Publication homepage - [All Posts](https://paragraph.com/@arych/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@arych): Subscribe to updates