blockchain - solidity - 单位和全局变量:msg, this, block, wei, gwei

发布时间: 2024-04-06 01:59:00

refer to:



this  代表当前合约

1 wei = 1

1 gwei = 1e9

1 ether = 1e18


1 minutes = 60  

1 hours = 3600


blockhash(uint blockNumber) returns (bytes32): hash of the given block when blocknumber is one of the 256 most recent blocks; otherwise returns zero

blobhash(uint index) returns (bytes32): versioned hash of the index-th blob associated with the current transaction. A versioned hash consists of a single byte representing the version (currently 0x01), followed by the last 31 bytes of the SHA256 hash of the KZG commitment (EIP-4844).

block.basefee (uint): current block’s base fee (EIP-3198 and EIP-1559)

block.blobbasefee (uint): current block’s blob base fee (EIP-7516 and EIP-4844)

block.chainid (uint): current chain id

block.coinbase (address payable): current block miner’s address

block.difficulty (uint): current block difficulty (EVM < Paris). For other EVM versions it behaves as a deprecated alias for block.prevrandao (EIP-4399 )

block.gaslimit (uint): current block gaslimit

block.number (uint): current block number

block.prevrandao (uint): random number provided by the beacon chain (EVM >= Paris)

block.timestamp (uint): current block timestamp as seconds since unix epoch

gasleft() returns (uint256): remaining gas (bytes calldata): complete calldata

msg.sender (address): sender of the message (current call)

msg.sig (bytes4): first four bytes of the calldata (i.e. function identifier)

msg.value (uint): number of wei sent with the message

tx.gasprice (uint): gas price of the transaction

tx.origin (address): sender of the transaction (full call chain)