Solidity tutorial – Global namespace

Solidity tutorial - Global namespace

The global namespace is a set of implicitly declared variables and functions that you can reference and use in your contract code directly.

Global variableMemberDescription
BlockBlockhash(unit blocknumber)Hash of given block
CoinbaseBlock’s miner’s address
gaslimitBlock’s gas limit
numberBlock’s number
timestampBlock’s timestamp as UNIX epoch
msgdataFull calldata body
senderMessage sender (who is performing the current call)
gasRemaining gas
valueAmount of Ether sent with the
message, in Wei
txgaspriceTransaction gas price
originTransaction sender (who originated the full call chain)

Global namespace for exception

require(bool condition): This is used to validate function
input.
assert(bool condition): This is used to validate contract
state or function state.

revert() : the execution and revert the contract state explicitly

selfdestruct (Ether recipient address): remove the current contract instance from the blockchain. This will uninstall the current instance from the blockchain and move the Ether present at the associated account to the specified recipient address

Global namespace for cryptographic hash functions

sha256()(from the SHA-2 family)

keccak256() (from the SHA-3family)

Leave a Reply

Your email address will not be published. Required fields are marked *