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 argumentsabi.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
): 當前塊的gaslimitblock.number
(uint
):當前塊的數量block.timestamp
(uint
):當前塊的時間戳gasleft() returns (uint256)
: 剩餘 gasmsg.data
(bytes
): 完整的calldatamsg.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個(緊湊排列的)參數的RIPEMDecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)
: 橢圓曲線簽名公鑰恢復,錯誤時返回0addmod(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地址,若失敗拋出異常。