pragma solidity ^0.4.0;

contract modifierTest{
bytes32 public blockhash;
address public coinbase;
uint public difficulty;
uint public gaslimit;
uint public blockNum;
uint public timestamp;
bytes public calldata1;
uint public gas;
address public sender;
bytes4 public sig;
uint public msgValue;
uint public now1;
uint public gasPrice;
address public txOrigin; function tt(){
//给定区块号的哈希值,只支持最近256个区块,且不包含当前区块
blockhash = block.blockhash(block.number -1);
coinbase = block.coinbase;//当前块矿工的地址
difficulty = block.difficulty;//当前块的难度
gaslimit = block.gaslimit;//当前块的gaslimit
blockNum = block.number; //当前区块的块号
timestamp = block.timestamp;//当前块的时间戳==now
calldata1 = msg.data;//完整的调用数据: 0x1e36169e
gas = msg.gas;//当前还剩下的gas
sender = msg.sender;//当前调用发起人的地址: 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c
sig = msg.sig;//调用数据的前4个字节(函数标识符): 0x1e36169e
msgValue = msg.value;//这个消息所携带的货币量,单位wei
now1 = now;
gasPrice = tx.gasprice;//交易的gas价格
txOrigin = tx.origin;//交易的发送者(完整的调用链): 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c
}
}
直接调用,后面无需()
  • abi.encode(...) returns (bytes):对给定的参数进行ABI编码。
  • abi.encodePacked(...) returns (bytes): Performes packed encoding of the given arguments
  • abi.encodeWithSelector(bytes4 selector, ...) returns (bytes)::对给定的参数进行ABI编码——从第二个预置给定的四字节选择器开始
  • abi.encodeWithSignature(string signature, ...) returns (bytes):相当于abi.encodeWithSelector(bytes4(keccak256(signature), ...)
  • block.blockhash(uint blockNumber) returns (bytes32): 给定的块的hash值, 只有最近工作的256个块的hash值—— 在 0.4.22 后请使用blockhash(uint blockNumber).
  • block.coinbase (address): 当前块的矿工的地址
  • block.difficulty (uint): 当前块的难度
  • block.gaslimit (uint): 当前块的gaslimit
  • block.number (uint):当前块的数量
  • block.timestamp (uint):当前块的时间戳
  • gasleft() returns (uint256): 剩余 gas
  • msg.data(bytes): 完整的calldata
  • msg.gas(uint): 剩余 gas - 0.4.21后请使用 gasleft()
  • msg.sender (address): 消息的发送者(当前调用)
  • msg.value (uint): 和消息一起发送的wei的数量
  • now (uint): 当前块的时间戳(block.timestamp的别名)
  • tx.gasprice (uint):交易的gas价格
  • tx.origin (address):交易的发送者(全调用链)
  • assert(bool condition): abort execution and revert state changes if condition is false (用于内部错误)
  • require(bool condition): abort execution and revert state changes if condition is false (用于输入错误或外部组件的错误)
  • require(bool condition, string message): abort execution and revert state changes if condition is false (用于输入错误或外部组件的错误). 并提供错误信息.
  • revert(): 中止执行并还原状态更改
  • revert(string message):中止执行并还原状态更改,提供解释字符串
  • blockhash(uint blockNumber) returns (bytes32): : 给定的块的hash值, 只有最近工作的256个块的hash值
  • keccak256(...) returns (bytes32):计算(紧凑排列的)参数的 Ethereum-SHA3 hash值
  • sha3(...) returns (bytes32): an alias to keccak256
  • sha256(...) returns (bytes32): 计算(紧凑排列的)参数的SHA256 hash值
  • ripemd160(...) returns (bytes20):计算 256个(紧凑排列的)参数的RIPEMD
  • ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address): 椭圆曲线签名公钥恢复,错误时返回0
  • addmod(uint x, uint y, uint k) returns (uint): compute (x + y) % k where the addition is performed with arbitrary precision and does not wrap around at 2**256. Assert that k != 0 starting from version 0.5.0.
  • mulmod(uint x, uint y, uint k) returns (uint): compute (x * y) % k where the multiplication is performed with arbitrary precision and does not wrap around at 2**256. Assert that k != 0 starting from version 0.5.0.
  • this (current contract’s type): 当前合约,在地址上显式转换
  • super: 在层次关系上一层的合约
  • selfdestruct(address recipient): 销毁当前的合约,将其资金发送到指定address
  • suicide(address recipient): a deprecated alias to selfdestruct
  • <address>.balance (uint256): address地址中的账户余额(以wei为单位)
  • <address>.send(uint256 amount) returns (bool): 将一定量wei发送给address地址,若失败返回false
  • <address>.transfer(uint256 amount): 将一定量wei发送给address地址,若失败抛出异常。

ethereum(以太坊)(九)--global(全局函数)的更多相关文章

  1. ethereum(以太坊)(一)

    从这周开始,开始学习以太坊开发--solidity,开始决定往区块链方向发展,毕竟区块链技术应用广泛.一开始接触solidity开发语言不太习惯,毕竟一直在学习python语法,有很多都不能接受.有难 ...

  2. ethereum(以太坊)(十)--函数修饰符

    pragma solidity ^0.4.0; contract modifierTest{ uint public v1; uint constant v2 =10; //uint constant ...

  3. ethereum(以太坊)(实例)--"安全的远程购买"

    pragma solidity ^0.4.10; contract Safebuy{ uint public price; address public seller; address public ...

  4. ethereum(以太坊)(十一)--字节数组(二)

    pragma solidity ^0.4.0; contract test { uint [5] T =[1,2,3,4,5] ;//固定长度的数组:可修改数组内值大小,不支持push,不可更改长度 ...

  5. ethereum(以太坊)(实例)--"简单的公开竞拍"

    说真的,刚开始接触这个竞拍案例--“简单的公开竞拍”,我就抱着简单的心态去查看这个实例,但是自我感觉并不简单.应该是我实力不到家的原因吧!!!233333...不过经过大半天的努力,自己理解完之后,觉 ...

  6. ethereum(以太坊)(基础)--容易忽略的坑(一)

    pragma solidity ^0.4.0; contract base{ address public _owner=msg.sender; uint _a; string internal _b ...

  7. ethereum(以太坊)(七)--枚举/映射/构造函数/修改器

    pragma solidity ^0.4.10; //枚举类型 contract enumTest{ enum ActionChoices{Left,Right,Straight,Still} // ...

  8. ethereum(以太坊)(四)--值传递与引用传递

    contract Person { string public _name; function Person() { _name = "liyuechun"; } function ...

  9. ethereum(以太坊)(三)--合约单继承与多继承

    pragma solidity ^0.4.0; // priveta public internal contract Test{ //defualt internal uint8 internal ...

随机推荐

  1. redis 读写锁实现

    一 先搞清楚读写锁要做什么. 基本就是 读读不互斥,读写互斥,写写互斥.可重入. 关于redis读写锁,我写了一次之后,总觉得很怪,然后就上网看到大神的redisson了,果断借鉴一番. 二 读行为 ...

  2. Unity C# 用枚举(enum)制作复选框

    最近在项目中做测试脚本用到一些布尔值做方法的开关,突然想到可以制作一个复选框控制开关. 首先搜集网上的资料,基本大同小异,这里就不多做解释了,代码附上: public class EnumFlagsA ...

  3. 前端性能优化-Cookie

    什么是Cookie Cookie可以理解成为浏览器内部存储数据的一个数据库,并会随请求一起被发送:Cookie以键-值对的形式存在.可以存储网站的一些数据,这部分数据不会随着浏览器关闭而被清除.如下图 ...

  4. 单元测试模拟request后台

    编写测试单元 @RunWith(SpringJUnit4ClassRunner.class) 让测试运行于Spring测试环境 @WebAppConfiguration是一个类级别的注释,用于声明Ap ...

  5. gulp 无损压缩图片

    在做项目中,美工有时候会给一些比较大的图片,在做网站的时候,图片太大会影响加载速度.因此,我们需要无损压缩图片. 在尝试过几个压缩图片的方法,发现gulp中的gulp-tinypng-nokey插件是 ...

  6. python面试题——前端(23题)

    2.谈谈你对websocket协议的认识. 3.什么是magic string ? 4.如何创建响应式布局? 5.你曾经使用过哪些前端框架? 6.什么是ajax请求?并使用jQuery和XMLHttp ...

  7. 【FPGA】Quartus导出.qxp格式的网表文件

    首先,右击项目顶层文件. 选择Design Partition -> Export Design Partition 即可完成.

  8. Eclipse导入web项目后,run列表中没有run on server?

    Eclipse导入web项目,没有run列表中run on server? 首先确保正确安装Tomcat和JDK .找到对于web项目的文件夹,打开文件夹下.project文件 <?xml ve ...

  9. 二叉查找树(c++)

    二叉查找数的操作: #include <iostream> using namespace std; typedef struct BitNode { int data; struct B ...

  10. Hive建模

    Hive建模 1.介绍 Hive作为数据仓库,同关系型数据库开发过程类似,都需要先进行建模,所谓建模,就是对表之间指定关系方式.建模在hive中大致分为星型.雪花型和星座型.要对建模深入理解,首先需要 ...