Solidity
Hello World
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Func {
string public str = "Hello World"; // 声明一个变量 赋值为hello world
// 写一个函数可以修改 str 变量的值
function setStr(string memory _str) public {
str = _str;
}
}
部署后的实现效果
solidity 对于变量有默认的 get方法 ,点击 str就能获取到结果,以及运行日志
点击 setStr 并且传值 然后会 修改 str 的值