Loading...
blockhash(uint blockNumber) returns (bytes32)
: hash of the given block - only works for 256 most recent, excluding current, blocksblock.chainid
(uint
): current chain idblock.coinbase
(address payable
): current block miner’s addressblock.difficulty
(uint
): current block difficultyblock.gaslimit
(uint
): current block gaslimitblock.number
(uint
): current block numberblock.timestamp
(uint
): current block timestamp as seconds since unix epochgasleft() returns (uint256)
: remaining gasmsg.data
(bytes calldata
): complete calldatamsg.sender
(address payable
): 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 messagetx.gasprice
(uint
): gas price of the transactiontx.origin
(address payable
): sender of the transaction (full call chain)Now let's learn how to use them
See the data types they have written inside the brackets near pre-defined functions are the datatypes that is returned when get called; not to confused with Arguments
Here are some examples how to use them
pragma solidity ^0.8.3;
contract Task2{
// create a function to return gas price of transaction and sender of transaction
//tx.gasprice (uint)
function getGasPrice()public view returns (uint){
return tx.gasprice ;
}
//tx.origin (address payable)
function getTransactionSender()public view returns (address){
return tx.origin ;
}
}
For many more exciting tutorials keep following my username @BlockTalks_Raj
!!!!!HAPPY LEARNING!!!!!