Module sui::tx_context
- Struct
TxContext
- Function
sender
- Function
native_sender
- Function
digest
- Function
native_digest
- Function
epoch
- Function
native_epoch
- Function
epoch_timestamp_ms
- Function
native_epoch_timestamp_ms
- Function
sponsor
- Function
native_sponsor
- Function
fresh_object_address
- Function
fresh_id
- Function
ids_created
- Function
native_ids_created
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>
Implementation
public fun digest(_self: &TxContext): &vector<u8> {
native_digest()
}
Function native_digest
fun native_digest(): &vector<u8>
Implementation
native fun native_digest(): &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> {
native_sponsor()
}
Function native_sponsor
fun native_sponsor(): std::option::Option<address>
Implementation
native fun native_sponsor(): Option<address>;
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;