GV:
and can be used directly in condition expressions, tracker update expressions, and other rule logic.
Available Global Variables
The following global variables are supported:Variable | Type | Description |
---|---|---|
GV:BLOCK_TIMESTAMP | uint256 | Current block timestamp (Unix timestamp) |
GV:MSG_DATA | bytes | Complete calldata of the current message |
GV:MSG_SENDER | address | Address of the message sender |
GV:BLOCK_NUMBER | uint256 | Current block number |
GV:TX_ORIGIN | address | Original external account that initiated the transaction |
Usage in Rule Conditions
Global variables can be used directly in condition expressions:Usage in Tracker Updates
Global variables can also be used in tracker update expressions:Common Use Cases
Time-based Logic
UseGV:BLOCK_TIMESTAMP
for implementing time-based restrictions, deadlines, or time windows:
Access Control
UseGV:MSG_SENDER
and GV:TX_ORIGIN
for implementing access control:
Transaction Analysis
UseGV:MSG_DATA
for analyzing transaction data or implementing complex validation logic:
Block-based Logic
UseGV:BLOCK_NUMBER
for implementing block-based logic, such as rate limiting or periodic operations:
Important Notes
Global variables are automatically available in all rule contexts. You don’t need to configure or
import them—they’re ready to use in any condition expression or effect.
When using
GV:MSG_SENDER
vs GV:TX_ORIGIN
, remember that:GV:MSG_SENDER
is the immediate caller (could be a contract)GV:TX_ORIGIN
is the original external account that initiated the transaction
GV:MSG_SENDER
for authentication and access control. Use GV:TX_ORIGIN
only when you specifically need to identify the original transaction initiator, and be aware of the security implications. OWASP Smart Contract Security articleGlobal variables reflect the current blockchain state at the time the rule is evaluated. Be aware
that block timestamps and numbers can vary slightly between different nodes, and
GV:BLOCK_TIMESTAMP
may not be perfectly accurate for time-sensitive applications.