Module sui::tx_context
- Struct 
TxContext - Function 
sender - Function 
native_sender - Function 
digest - Function 
epoch - Function 
native_epoch - Function 
epoch_timestamp_ms - Function 
native_epoch_timestamp_ms - Function 
sponsor - Function 
fresh_object_address - Function 
fresh_id - Function 
ids_created - Function 
native_ids_created - Function 
native_gas_price - Function 
native_gas_budget - Function 
option_sponsor - Function 
native_sponsor - Function 
derive_id 
use std::option;
use std::vector;
Struct TxContext
Information about the transaction currently being executed. This cannot be constructed by a transaction--it is a privileged object created by the VM and passed in to the entrypoint of the transaction as &mut TxContext.
public struct TxContext has drop
Fields
- sender: address
 - The address of the user that signed the current transaction
 - tx_hash: vector<u8>
 - Hash of the current transaction
 - epoch: u64
 - The current epoch number
 - epoch_timestamp_ms: u64
 - Timestamp that the epoch started at
 - ids_created: u64
 - Counter recording the number of fresh id's created while executing this transaction. Always 0 at the start of a transaction
 
Function sender
Return the address of the user that signed the current transaction
public fun sender(_self: &sui::tx_context::TxContext): address
Implementation
public fun sender(_self: &TxContext): address {
    native_sender()
}
Function native_sender
fun native_sender(): address
Implementation
native fun native_sender(): address;
Function digest
Return the transaction digest (hash of transaction inputs). Please do not use as a source of randomness.
public fun digest(self: &sui::tx_context::TxContext): &vector<u8>
Function epoch
Return the current epoch
public fun epoch(_self: &sui::tx_context::TxContext): u64
Implementation
public fun epoch(_self: &TxContext): u64 {
    native_epoch()
}
Function native_epoch
fun native_epoch(): u64
Implementation
native fun native_epoch(): u64;
Function epoch_timestamp_ms
Return the epoch start time as a unix timestamp in milliseconds.
public fun epoch_timestamp_ms(_self: &sui::tx_context::TxContext): u64
Implementation
public fun epoch_timestamp_ms(_self: &TxContext): u64 {
    native_epoch_timestamp_ms()
}
Function native_epoch_timestamp_ms
fun native_epoch_timestamp_ms(): u64
Implementation
native fun native_epoch_timestamp_ms(): u64;
Function sponsor
Return the adress of the transaction sponsor or None if there was no sponsor.
public fun sponsor(_self: &sui::tx_context::TxContext): std::option::Option<address>
Implementation
public fun sponsor(_self: &TxContext): Option<address> {
    option_sponsor()
}
Function fresh_object_address
Create an address that has not been used. As it is an object address, it will never occur as the address for a user. In other words, the generated address is a globally unique object ID.
public fun fresh_object_address(_ctx: &mut sui::tx_context::TxContext): address
Implementation
public fun fresh_object_address(_ctx: &mut TxContext): address {
    fresh_id()
}
Function fresh_id
fun fresh_id(): address
Implementation
native fun fresh_id(): address;
Function ids_created
Return the number of id's created by the current transaction. Hidden for now, but may expose later
fun ids_created(_self: &sui::tx_context::TxContext): u64
Implementation
fun ids_created(_self: &TxContext): u64 {
    native_ids_created()
}
Function native_ids_created
fun native_ids_created(): u64
Implementation
native fun native_ids_created(): u64;
Function native_gas_price
fun native_gas_price(): u64
Implementation
native fun native_gas_price(): u64;
Function native_gas_budget
fun native_gas_budget(): u64
Implementation
native fun native_gas_budget(): u64;
Function option_sponsor
fun option_sponsor(): std::option::Option<address>
Implementation
fun option_sponsor(): Option<address> {
    let sponsor = native_sponsor();
    if (sponsor.length() == 0) option::none() else option::some(sponsor[0])
}
Function native_sponsor
fun native_sponsor(): vector<address>
Implementation
native fun native_sponsor(): vector<address>;
Function derive_id
Native function for deriving an ID via hash(tx_hash || ids_created)
fun derive_id(tx_hash: vector<u8>, ids_created: u64): address
Implementation
native fun derive_id(tx_hash: vector<u8>, ids_created: u64): address;