demo.sol(内置全局函数):
pragma solidity ^0.4.21;
contract Test {
bytes32 public blockhash;
address public coinbase;
uint public difficulty;
uint public gaslimit;
uint public blockNum;
uint public timestamp;
bytes public calldata;
uint public gas;
address public sender;
bytes4 public sig;
uint public msgValue;
uint public _now;
uint public gasPrice;
address public txOrigin;
function tt () payable public {
//给定区块号的哈希值,只支持最近256个区块,且不包含当前区块
blockhash = block.blockhash(block.number - 1);
coinbase = block.coinbase ; //当前块矿工的地址。
difficulty = block.difficulty; //当前块的难度。
gaslimit = block.gaslimit; // (uint)当前块的gaslimit。
blockNum = block.number; // (uint)当前区块的块号。
timestamp = block.timestamp; // (uint)当前块的时间戳。
calldata = msg.data; // (bytes)完整的