Transaction

Type-safe C++ wrappers for transaction C API. More...

Classes

Type Name
class eosio::transaction_header
Contains details about the transaction.
class eosio::transaction
struct eosio::onerror

Typedefs

Functions

Detailed Description

An inline message allows one contract to send another contract a message which is processed immediately after the current message's processing ends such that the success or failure of the parent transaction is dependent on the success of the message. If an inline message fails in processing then the whole tree of transactions and actions rooted in the block will me marked as failing and none of effects on the database will persist. Inline actions and Deferred transactions must adhere to the permissions available to the parent transaction or, in the future, delegated to the contract account for future use.

Note:

There are some methods from the transactioncapi that can be used directly from C++

Typedefs Documentation

typedef extension

typedef std::tuple<uint16_t, std::vector<char> > eosio::extension;

typedef extensions_type

typedef std::vector<extension> eosio::extensions_type;

Functions Documentation

function from_current_action

static static onerror eosio::onerror::from_current_action()

from_current_action unpacks and returns a onerror struct

function send_deferred

void eosio::send_deferred(
    const uint128_t & sender_id,
    name payer,
    const char * serialized_transaction,
    size_t size,
    bool replace = false
)

Send a deferred transaction

Parameters:

  • sender_id - Account name of the sender of this deferred transaction
  • payer - Account name responsible for paying the RAM for this deferred transaction
  • serialized_transaction - The packed transaction to be deferred
  • size - The size of the packed transaction, required for persistence.
  • replace - If true, will replace an existing transaction.

function get_action

action eosio::get_action(
    uint32_t type,
    uint32_t index
)

Retrieve the indicated action from the active transaction.

Parameters:

  • type - 0 for context free action, 1 for action
  • index - the index of the requested action

Returns:

the indicated action

function read_transaction

size_t eosio::read_transaction(
    char * ptr,
    size_t sz
)

Access a copy of the currently executing transaction.

Access a copy of the currently executing transaction.

Returns:

the currently executing transaction

function cancel_deferred

int eosio::cancel_deferred(
    const uint128_t & sender_id
)

Cancels a deferred transaction.

Parameters:

  • sender_id - The id of the sender

Precondition:

The deferred transaction ID exists.

Precondition:

The deferred transaction ID has not yet been published.

Post

Deferred transaction canceled.

Returns:

1 if transaction was canceled, 0 if transaction was not found

Example:

id = 0xffffffffffffffff
cancel_deferred( id );

function transaction_size

size_t eosio::transaction_size()

Gets the size of the currently executing transaction.

Gets the size of the currently executing transaction.

Returns:

size of the currently executing transaction

function tapos_block_num

int eosio::tapos_block_num()

Gets the block number used for TAPOS on the currently executing transaction.

Gets the block number used for TAPOS on the currently executing transaction.

Returns:

block number used for TAPOS on the currently executing transaction Example:

int tbn = tapos_block_num();

function tapos_block_prefix

int eosio::tapos_block_prefix()

Gets the block prefix used for TAPOS on the currently executing transaction.

Gets the block prefix used for TAPOS on the currently executing transaction.

Returns:

block prefix used for TAPOS on the currently executing transaction Example:

int tbp = tapos_block_prefix();

function expiration

uint32_t eosio::expiration()

Gets the expiration of the currently executing transaction.

Gets the expiration of the currently executing transaction.

Returns:

expiration of the currently executing transaction in seconds since Unix epoch

function get_context_free_data

int eosio::get_context_free_data(
    uint32_t index,
    char * buff,
    size_t size
)

Retrieve the signed_transaction.context_free_data[index].

Retrieve the signed_transaction.context_free_data[index].

Parameters:

  • index - the index of the context_free_data entry to retrieve
  • buff - output buff of the context_free_data entry
  • size - amount of context_free_data[index] to retrieve into buff, 0 to report required size

Returns:

size copied, or context_free_data[index].size() if 0 passed for size, or -1 if index not valid