sui::tx_context
TxContext
sender
native_sender
digest
epoch
native_epoch
epoch_timestamp_ms
native_epoch_timestamp_ms
sponsor
fresh_object_address
fresh_id
reference_gas_price
native_rgp
gas_price
native_gas_price
native_ids_created
native_gas_budget
option_sponsor
native_sponsor
derive_id
use std::option;
use std::vector;
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
sender: address
tx_hash: vector<u8>
epoch: u64
epoch_timestamp_ms: u64
ids_created: u64
sender
Return the address of the user that signed the current transaction
public fun sender(_self: &sui::tx_context::TxContext): address
public fun sender(_self: &TxContext): address {
native_sender()
}
native_sender
fun native_sender(): address
native fun native_sender(): address;
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>
epoch
Return the current epoch
public fun epoch(_self: &sui::tx_context::TxContext): u64
public fun epoch(_self: &TxContext): u64 {
native_epoch()
}
native_epoch
fun native_epoch(): u64
native fun native_epoch(): u64;
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
public fun epoch_timestamp_ms(_self: &TxContext): u64 {
native_epoch_timestamp_ms()
}
native_epoch_timestamp_ms
fun native_epoch_timestamp_ms(): u64
native fun native_epoch_timestamp_ms(): u64;
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>
public fun sponsor(_self: &TxContext): Option<address> {
option_sponsor()
}
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
public fun fresh_object_address(_ctx: &mut TxContext): address {
fresh_id()
}
fresh_id
fun fresh_id(): address
native fun fresh_id(): address;
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
public fun reference_gas_price(_self: &TxContext): u64 {
native_rgp()
}
native_rgp
fun native_rgp(): u64
native fun native_rgp(): u64;
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
public fun gas_price(_self: &TxContext): u64 {
native_gas_price()
}
native_gas_price
fun native_gas_price(): u64
native fun native_gas_price(): u64;
native_ids_created
fun native_ids_created(): u64
native fun native_ids_created(): u64;
native_gas_budget
fun native_gas_budget(): u64
native fun native_gas_budget(): u64;
option_sponsor
fun option_sponsor(): std::option::Option<address>
fun option_sponsor(): Option<address> {
let sponsor = native_sponsor();
if (sponsor.length() == 0) option::none() else option::some(sponsor[0])
}
native_sponsor
fun native_sponsor(): vector<address>
native fun native_sponsor(): vector<address>;
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
native fun derive_id(tx_hash: vector<u8>, ids_created: u64): address;