Search
# Global Variables, Functions and Members
There are special variables and functions which always exist in the global namespace and are mainly used to provide information about the blockchain or are general-use utility functions.
# Block and Transaction Properties
block.number
(uint
): current snapshot block heightblock.timestamp
(uint
): current snapshot block timestamp as seconds since unix epochmsg.data
(bytes calldata
): complete calldatamsg.sender
(address
): sender of the message (current call)msg.sig
(bytes4
): first four bytes of the calldata (i.e. function identifier)msg.value
(uint
): amount of a specific token sent with the messagetx.origin
(address
): sender of the transaction (full call chain)
Strictly speaking, due to the asynchronous nature of Vite,
block.number
andblock.timestamp
returns the result of the snapshot block that the request transaction was included in, NOT precisely the current snapshot block.
The following are available in Solidity but not in Solidity++:
To support additional Vite features, Solidity++ has been extended with the following functions and members:
fromhash() returns (bytes32)
: hash of the request transactionprevhash() returns (bytes32)
: hash of the latest block on the contract's account chainaccountheight() returns (uint)
: height of the latest block on the contract's account chainrandom64() returns (uint64)
: random number (returns the same random number in one transaction)nextrandom() returns (uint64)
: random number (can be called multiple times to obtain different random numbers in one transaction)balance(vitetoken) returns (uint256)
: balance of the contract for the specified vitetokenmsg.token
(vitetoken
): token identifier sent with the messagepayable(address).transfer(vitetoken, uint256)
: sends some amount of a specific token to an addressblake2b(bytes memory) returns (bytes32)
: computes the BLAKE2b hash of the input
For a complete list please refer to https://docs.soliditylang.org/en/v0.8.1/units-and-global-variables.html#special-variables-and-functions (opens new window)