ethereum(以太坊)(八)--Address
pragma solidity ^0.4.0; contract Test{ address _owner;
uint160 _c; constructor() public{
_owner = 0xca35b7d915458ef540ade6068dfe2f44e8fa733c;
_c = 1154414090619811796818182302139415280051214250812;
} /*
address _owner;
uint160 _c; function inter(){
_owner = 0xca35b7d915458ef540ade6068dfe2f44e8fa733c;
//ca35b7d915458ef540ade6068dfe2f44e8fa733c
//40 * 4 = 160
_c = 1154414090619811796818182302139415280051214250812;
}
0x 45 :16进制
0b 0 1 0 0 0 1 0 1 :2进制
128+64+32+16 +8+4+2+1 69 :10进制
*/
function getUint160() constant returns(uint160){
return uint160(_owner);
} function getAddress() constant returns(address){
return address(_c);
}
} /*
to 0xbde95422681e4c3984635af2f2f35f8c44a4ddc9
contract address 0x0fdf4894a3b7c5a101686829063be52ad45bcfb7
from 0xca35b7d915458ef540ade6068dfe2f44e8fa733c
*/ pragma solidity ^0.4.0; contract modifierTest{
address owner;
uint public v3; constructor() public{
uint8 _a = 12 ;
uint b = 1;
string memory str='eilinge';
owner =msg.sender;
}
/*
function setAddress(address add) public{
owner= add;
} function getAddress() constant returns(address){
return owner;
}
*/ modifier onlyowner(address own) {
require(own == owner);
_;
}
//msg.sender 部署合约时的地址
//在Account切换成其他地址,不需要重新部署合约,直接运行即可
//modifierTest at 0xcac3f0403895fadae1c5cb2f9cb5fb0fbda62a37(memory) 当前合约对象的地址
function setv3() onlyowner(msg.sender) returns(uint){
return v3 += 10;
}
function getthisAddress() constant returns(address){
return this; //xCac3f0403895fAdAE1c5Cb2F9cB5fB0FbDa62a37
}
function getBalance(address add) constant returns(uint){
return add.balance; //参看钱包地址余额:getBalance("0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db") 传入参数需要添加("")
}
} pragma solidity ^0.4.0; contract modifierTest{
address public accounts=0xdd870fa1b7c4700f2bd7f44238821c26f7392148;
address owner= msg.sender; function transfertest() payable public returns(bool){ //payable 转账必须加上
//accounts = 0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db;
accounts.transfer(msg.value); //msg.value 全局变量,在value中直接赋值
return accounts.send(msg.value);
/*
send():
递归深度不能超过1024
如果gas不够,执行会失败,只会返回false,不能报异常
检查是否转账成功
transfer 相对 send 较安全
*/
} function getbalance() constant public returns(uint){ return accounts.balance;
} function getownerbalance() constant public returns(uint){ return owner.balance;
}
}
ethereum(以太坊)(八)--Address的更多相关文章
- ethereum(以太坊)(一)
从这周开始,开始学习以太坊开发--solidity,开始决定往区块链方向发展,毕竟区块链技术应用广泛.一开始接触solidity开发语言不太习惯,毕竟一直在学习python语法,有很多都不能接受.有难 ...
- ethereum(以太坊)(实例)--"安全的远程购买"
pragma solidity ^0.4.10; contract Safebuy{ uint public price; address public seller; address public ...
- ethereum(以太坊)(实例)--"简单的公开竞拍"
说真的,刚开始接触这个竞拍案例--“简单的公开竞拍”,我就抱着简单的心态去查看这个实例,但是自我感觉并不简单.应该是我实力不到家的原因吧!!!233333...不过经过大半天的努力,自己理解完之后,觉 ...
- ethereum(以太坊)(基础)--容易忽略的坑(二)
pragma solidity ^0.4.0; contract EMath{ string public _a="lin"; function f() public{ modif ...
- ethereum(以太坊)(基础)--容易忽略的坑(一)
pragma solidity ^0.4.0; contract base{ address public _owner=msg.sender; uint _a; string internal _b ...
- ethereum(以太坊)(十三)--异常处理/元祖
pragma solidity ^0.4.4; contract Students{ uint[] data= new uint[](4); address _owner = msg.sender; ...
- ethereum(以太坊)(十二)--应用(二)__投票(基础总和)
编写应用合约之前,先弄清它的逻辑,有助于我们更好的部署合约 pragma solidity ^0.4.21; pragma experimental ABIEncoderV2; contract vo ...
- ethereum(以太坊)(十二)--应用(一)__集资(构造函数/映射)
pragma solidity ^0.4.4; contract funder{ //0xca35b7d915458ef540ade6068dfe2f44e8fa733c //0x14723a09ac ...
- ethereum(以太坊)(十)--函数修饰符
pragma solidity ^0.4.0; contract modifierTest{ uint public v1; uint constant v2 =10; //uint constant ...
随机推荐
- Functional language(函数式编程语言)初步了解
对于函数式语言并不太了解,查询了百度.博客.知乎等做了以下总结. What 函数式语言(functional language)一类程序设计语言,是一种非冯·诺伊曼式的程序设计语言.函数式语言主要成分 ...
- Java Knowledge series 7
Pepole who make a greate contribution on common libaraies deserve our respect. Component(Widget) / S ...
- Struts2_带参数的结果集
页面请求: <a href="user/user?type=1">传参数</a> action: public Integer type; public S ...
- Struts1.x 基本原理及注册模块的实现
1.编写JavaBean:User,必须继承于ActionForm类 package myuser; import org.apache.struts.action.ActionForm; publi ...
- check_mk插件 redis
/usr/lib/check_mk_agent/plugins/mk_redis #!/bin/bash echo '<<<redis>>>' hosts=$(ne ...
- centos系统下安装Nginx
参考链接 CentOS 7 用 yum 安装 Nginx Nginx负载均衡配置 下载并安装 #使用以下命令 sudo yum install -y nginx #sudo表示使用管理员权限运行命令 ...
- python从字符串中提取数字,使用正则表达式
使用正则表达式 import re D = re.findall(r"\d+\.?\d*",line) print(D) -7.23246 10.8959 5.19534 0.06 ...
- 关于tcp的keepalive
先记录几个要点 只能用在面向连接的tcp中,对应对端的非正常关闭有效(对端服务器重启这种,也是正常关闭,FIN RST包都算) 只要是写入到缓冲区就认为OK,所以UDP不适合,所以如果有正常的网络交互 ...
- 四大CPU体系结构ARM、X86/Atom、MIPS、PowerPC
http://blog.csdn.net/wangjianno2/article/details/52140936 RISC(reduced instruction set computer,精简指令 ...
- LA 3635 派
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...