Solidity

基于初学者我们使用在线的Solidity的IDE。地址为:https://remix.ethereum.org
还需要准备MetaMask插件。在插件商店可以下载,这里就不提供下载方式了。

Helloworld的编写

首先我们写一个Helloworld的文件。
在Solidity里面新建一个sol文件
在这里插入图片描述然后在右边对它进行编写

pragma solidity ^0.4.0;					//编译器的版本,可以兼容0.4.x的版本不兼容0.5.x的版本、

contract Helloworld{
    string str = "Helloworld";
    
    function getstr() public view returns(string)		//读字符串 不消耗燃料
    {
        return str;
    }
    function changeName(string _newstr) public	//改字符串  消耗燃料
    {
        str = _newstr;
    }
    function pureTest(string _name) pure public returns(string){		//传入什么字符串就返回什么字符串	pure	不消耗燃料
        return _name;
    }
}

真假Boolean值

新建一个Boolean.sol
观察值

pragma solidity ^0.4.0;

contract BooleanTest{
    
    bool _a;
    
    function getBool() public view returns(bool)
    {
        return _a;		//false(!_a 是true)
    }
}

&& 和 ||
false && false = false;
true && false = false;
false && true = false;
true && true = true;
true || false = true;
false || true = true;
true || true = true;
false || false = false;

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值