ethereum(以太坊)(基础)--容易忽略的坑(二)
pragma solidity ^0.4.0; contract EMath{ string public _a="lin"; function f() public{
modify(_a);
} //function modify(string storage name) private{
function modify(string memory name) private{
//string storage c = name;Type string memory is not implicitly convertible to expected type string storage pointer
var c = name;
bytes(c)[0] ='L';
} //uint8 ~ uint256
//0000 0000 ~ 1111 1111
//0 ~255
//int8 ~ int256
//1111 1111 ~ 0111 1111
//-127 + 127 +0 =255 uint8 a=3;
//0000 0011
uint8 b=6;
//0000 0110
function yihuo() view returns(uint){
return a ^ b;
/*
0000 0011
0000 0110
0000 0101
*/
} function yifeihuo() view public returns(uint16){
return ~(a ^ (~b));
/*
0000 0011 0000 0110
1111 1001 1111 1010
*/
} function huo() returns(uint){
return a | b;
/*
0000 0011
0000 0110 0000 0111
*/
} function yu() returns(uint){
return a & b;
/*
0000 0011
0000 0110 0000 0010
*/
}
function left() returns(uint8){
return a<<2;
/*
0000 0011 0000 1100
*/
} enum Cants{left,right,mid} Cants public def=Cants.left; function re(Cants c1) returns(bool){
if (def ==c1){
return true;
}
} struct fun{
uint _id;
string _name;
uint _sex;
} //0x14723a09acff6d2a60dcdf7aa4aff308fddc160c
//0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db fun n1=fun(0,'eilinge',1);
fun n2=fun(1,'lin',0); fun[] public funs;
fun[] public funids; function p1() public{
funs.push(n1);
funs.push(n2);
} uint funid;
mapping(address=> fun) addfun; function p2(address na1) public{
fun memory f1 =addfun[na1];
//f1(2,'eil',0);type is not callable
f1._id=2;
}
} contract Addr{
address _owner =0xca35b7d915458ef540ade6068dfe2f44e8fa733c;
uint160 _c = 1154414090619811796818182302139415280051214250812;
/*
0x ca35b7d915458ef540ade6068dfe2f44e8fa733c :.legnth=40
c a
0b 1100 1010 :.length=40*4=uint160
*/
function f1() constant returns(uint160){
return uint160(_owner);
} function f2() constant returns(address){
return address(_c);
} function getBalance(address add) payable returns(bool){
//return add.balance;
add.transfer(msg.value);//msg.sender => add
} bytes1 _a=0xf0;
//0010 0010; 1*8
bytes32 public _b=0x231231;
//32*8 function getLeng() returns(bytes1){
//return _b.length;
return _a[0];
}
function getLeng1() {
//_b.length =5;Expression has to be an lvalue
} string public _d='lilianjie';
//bytes public _f =new bytes;type function (uint256) pure returns (bytes memory)
//is not implicitly convertible to expected type bytes storage ref
bytes public _f =new bytes(2); function bytestring() constant returns(bytes){
return bytes(_d);
}
function stringbytes() constant returns(string){
return string(_f);
}
function modifybytes() public{
//_d.length=5;
//Member "length" not found or not visible after argument-dependent lookup in string storage ref
bytes(_d).length=5;
_f.length=3;
//_d[0]='E';Member "length" not found or not visible after argument-dependent lookup in string storage ref bytes(_d)[0]="L";
}
}
ethereum(以太坊)(基础)--容易忽略的坑(二)的更多相关文章
- ethereum(以太坊)(基础)--容易忽略的坑(三)
pragma solidity ^0.4.10; contract Byte{ bytes [] public T=new bytes[](3); function setLeng(uint len) ...
- ethereum(以太坊)(基础)--容易忽略的坑(一)
pragma solidity ^0.4.0; contract base{ address public _owner=msg.sender; uint _a; string internal _b ...
- C#以太坊基础入门
在这一部分,我们将使用C#开发一个最简单的.Net控制台应用,来接入以太坊节点,并打印 所连接节点旳版本信息.通过这一部分的学习,你将掌握以下技能: 如何使用节点仿真器 如何在命令行访问以太坊节点 如 ...
- ethereum(以太坊)(一)
从这周开始,开始学习以太坊开发--solidity,开始决定往区块链方向发展,毕竟区块链技术应用广泛.一开始接触solidity开发语言不太习惯,毕竟一直在学习python语法,有很多都不能接受.有难 ...
- c#实战开发:以太坊钱包对接私链 (二)
上一篇讲了 以太坊私链搭建 首先下载Ethereum Wallet 钱包 可以直接百度 下载如果直接打开它会默认连接公链 所以我们要通过命令打开 "F:\Program Files\Ethe ...
- 以太坊 layer2: optimism 源码学习(二) 提现原理
作者:林冠宏 / 指尖下的幽灵.转载者,请: 务必标明出处. 掘金:https://juejin.im/user/1785262612681997 博客:http://www.cnblogs.com/ ...
- ethereum(以太坊)(十二)--应用(二)__投票(基础总和)
编写应用合约之前,先弄清它的逻辑,有助于我们更好的部署合约 pragma solidity ^0.4.21; pragma experimental ABIEncoderV2; contract vo ...
- ethereum(以太坊)(实例)--"安全的远程购买"
pragma solidity ^0.4.10; contract Safebuy{ uint public price; address public seller; address public ...
- ethereum(以太坊)(实例)--"简单的公开竞拍"
说真的,刚开始接触这个竞拍案例--“简单的公开竞拍”,我就抱着简单的心态去查看这个实例,但是自我感觉并不简单.应该是我实力不到家的原因吧!!!233333...不过经过大半天的努力,自己理解完之后,觉 ...
随机推荐
- Win10系统安装iis的方法【图文教程】
1.在win10系统中的开始按钮点击右键,选择控制面板: 2.从控制面板选择“程序”: 然后选择“启用或关闭windows功能” 3.从列表中选择Internet Infomation Service ...
- vuejs源码摘抄(二)
创建一个用来观察对象的observe类,这个类会附加在被观察的对象上,并且把被观察对象的属性值转换成getter/setter,同时,收集依赖和分发更新,实现代码如下: /* * not type c ...
- js贪食蛇
<!DOCTYPE html><head><title>canvas贪食蛇</title><style>.canvas{ backgr ...
- arcgis 10.2 安装教程(含下载地址)
http://jingyan.baidu.com/article/fc07f98911b66912ffe5199b.html 2013年7月,Esri即将推出全新的版本——ArcGIS 10.2,那些 ...
- 【2015 Week Task】
2015 第17周 task:项目语音识别技术整理 2015 第18周 task:项目key技术整理
- mysql在表的某一位置增加一列、删除一列、修改列名
如果想在一个已经建好的表中添加一列,可以用以下代码: ) not null; 这条语句会向已有的表中加入一列,这一列在表的最后一列位置.如果我们希望添加在指定的一列,可以用: ) not null a ...
- 【Leetcode】【Easy】Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...
- vue-cli3 项目从搭建优化到docker部署
项目地址 vue-cli3-project 欢迎 star 原文地址 https://www.ccode.live/lentoo/list/9?from=art 1. 创建一个vue项目 相信大部分人 ...
- POJ 1681 Painter's Problem 【高斯消元 二进制枚举】
任意门:http://poj.org/problem?id=1681 Painter's Problem Time Limit: 1000MS Memory Limit: 10000K Total ...
- Latex 编辑器安装
MiKTex + TexStudio 1. 下载安装MiKTex,从http://www.miktex.org/下载basic-miktex-2.9.5872-x64.exe,一路默认安装... 或者 ...