Skip to content

Latest commit

 

History

History
258 lines (123 loc) · 6.93 KB

tx_context.md

File metadata and controls

258 lines (123 loc) · 6.93 KB

Module 0x2::tx_context

Struct TxContext

Information about the transaction currently being executed.

struct TxContext

Struct ModuleUpgradeFlag

struct ModuleUpgradeFlag has copy, drop, store

Constants

const ErrorInvalidContext: u64 = 1;

Function sender

Return the address of the user that signed the current transaction

public fun sender(): address

Function sequence_number

Return the sequence number of the current transaction

public fun sequence_number(): u64

Function max_gas_amount

Return the max gas to be used

public fun max_gas_amount(): u64

Function fresh_address

Generate a new unique address,

public fun fresh_address(): address

Function derive_id

public(friend) fun derive_id(hash: vector<u8>, index: u64): address

Function tx_hash

Return the hash of the current transaction

public fun tx_hash(): vector<u8>

Function add_attribute_via_system

Add a value to the context map via system reserved address

public fun add_attribute_via_system<T: copy, drop, store>(system: &signer, value: T)

Function get_attribute

Get attribute value from the context map

public fun get_attribute<T: copy, drop, store>(): option::Option<T>

Function contains_attribute

Check if the key is in the context map

public fun contains_attribute<T: copy, drop, store>(): bool

Function tx_meta

Get the transaction meta data The TxMeta is writed by the VM before the transaction execution. The meta data is only available when executing or validating a transaction, otherwise abort(eg. readonly function call).

public fun tx_meta(): tx_meta::TxMeta

Function tx_gas_payment_account

Get the gas payment account of the transaction Currently, the gas payment account is the sender of the transaction. In the future, the gas payment account may be different from the sender.

public fun tx_gas_payment_account(): address

Function tx_result

The result is only available in the post_execute function.

Function is_system_call

Check if the current transaction is a system call The system call is a special transaction initiated by the system.

public fun is_system_call(): bool

Function set_module_upgrade_flag

public(friend) fun set_module_upgrade_flag(is_upgrade: bool)

Function drop

public fun drop(self: tx_context::TxContext)