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 reference_gas_price
- Function native_rgp
- Function gas_price
- Function native_gas_price
- Function native_ids_created
- 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
Function native_sender
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
Function native_epoch
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
Function native_epoch_timestamp_ms
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>
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
Function fresh_id
fun fresh_id(): address
Function reference_gas_price
Return the reference gas price in effect for the epoch the transaction is being executed in.
public fun reference_gas_price(_self: &sui::tx_context::TxContext): u64
Function native_rgp
fun native_rgp(): u64
Function gas_price
Return the gas price submitted for the current transaction.
That is the value the user submitted with the transaction data.
public fun gas_price(_self: &sui::tx_context::TxContext): u64
Function native_gas_price
fun native_gas_price(): u64
Function native_ids_created
fun native_ids_created(): u64
Function native_gas_budget
fun native_gas_budget(): u64
Function option_sponsor
fun option_sponsor(): std::option::Option<address>
Function native_sponsor
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