Global Variables
In Rubidity, you have access to several built-in global objects within Dumb Contracts to interact with the Ethereum network and transactions. These globals are analogous to the msg
, tx
, and block
objects in Solidity.
Here's an example:
Here's a look at some of these globals:
msg
The msg
global provides access to the message sender's details.
Properties
msg.sender
: Represents the address of the account that is directly responsible for this transaction. Its type is eitheraddressOrDumbContract
.
Usage
tx
The tx
global offers details about the transaction.
Properties
tx.origin
: Indicates the address of the externally owned account that initiated the transaction. Its type isaddress
.
Usage
block
The block
global provides details about the current block.
Properties
block.number
: The block number. Its type isuint256
.block.timestamp
: The block timestamp. Its type isdatetime
.
Methods
block.blockhash(block_number)
: Retrieves the hash of a block by its number.
Usage
esc
The esc
global is unique to Rubidity and is tailored for Ethscriptions.
Methods
esc.getEthscriptionById(ethscription_id)
: Finds an Ethscription by its ID and returns a structured response containing details like block number, creator, current owner, and so on.
Usage
Rubidity doesn't currently support structs, but the return value of getEthscriptionById is a special case. It behaves as if it was this struct:
Last updated