Skip to main content

Module iota::tx_context

use std::option; use std::vector;

Module Functions

prv 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;

prv fresh_id

fun fresh_id(): address

Implementation

native fun fresh_id(): address;

prv native_digest

fun native_digest(): &vector

Implementation

native fun native_digest(): &vector;

prv native_epoch

fun native_epoch(): u64

Implementation

native fun native_epoch(): u64;

prv native_epoch_timestamp_ms

fun native_epoch_timestamp_ms(): u64

Implementation

native fun native_epoch_timestamp_ms(): u64;

prv native_gas_budget

fun native_gas_budget(): u64

Implementation

native fun native_gas_budget(): u64;

prv native_gas_price

fun native_gas_price(): u64

Implementation

native fun native_gas_price(): u64;

prv native_ids_created

fun native_ids_created(): u64

Implementation

native fun native_ids_created(): u64;

prv native_rgp

fun native_rgp(): u64

Implementation

native fun native_rgp(): u64;

prv native_sender

fun native_sender(): address

Implementation

native fun native_sender(): address;

prv native_sponsor

fun native_sponsor(): vector<address>

Implementation

native fun native_sponsor(): vector<address>;

prv 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]) }

Structs

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

pub digest

Return the transaction digest (hash of transaction inputs). Please do not use as a source of randomness.

public fun digest(_self: &iota::tx_context::TxContext): &vector

Implementation

public fun digest(_self: &TxContext): &vector {     native_digest() }

pub epoch

Return the current epoch

public fun epoch(_self: &iota::tx_context::TxContext): u64

Implementation

public fun epoch(_self: &TxContext): u64 {     native_epoch() }

pub epoch_timestamp_ms

Return the epoch start time as a unix timestamp in milliseconds.

public fun epoch_timestamp_ms(_self: &iota::tx_context::TxContext): u64

Implementation

public fun epoch_timestamp_ms(_self: &TxContext): u64 {     native_epoch_timestamp_ms() }

pub 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 iota::tx_context::TxContext): address

Implementation

public fun fresh_object_address(_ctx: &mut TxContext): address {     fresh_id() }

pub gas_budget

Return the gas budget for the current transaction.

public fun gas_budget(_self: &iota::tx_context::TxContext): u64

Implementation

public fun gas_budget(_self: &TxContext): u64 {     native_gas_budget() }

pub 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: &iota::tx_context::TxContext): u64

Implementation

public fun gas_price(_self: &TxContext): u64 {     native_gas_price() }

pub 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: &iota::tx_context::TxContext): u64

Implementation

public fun reference_gas_price(_self: &TxContext): u64 {     native_rgp() }

pub sender

Return the address of the user that signed the current transaction

public fun sender(_self: &iota::tx_context::TxContext): address

Implementation

public fun sender(_self: &TxContext): address {     native_sender() }

pub sponsor

Return the address of the transaction sponsor or None if there was no sponsor.

public fun sponsor(_self: &iota::tx_context::TxContext): std::option::Option<address>

Implementation

public fun sponsor(_self: &TxContext): Option<address> {     option_sponsor() }