Transaction C++ API

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


Type Name
class eosio::transaction_header
Contains details about the transaction.
class eosio::transaction
Contains the actions, context_free_actions and extensions type for a transaction.
struct eosio::onerror
Contains and sender id and packed transaction.



Detailed Description


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

Variables Documentation

variable expiration

time_point_sec eosio::transaction_header::expiration;

variable ref_block_num

uint16_t eosio::transaction_header::ref_block_num;

variable ref_block_prefix

uint32_t eosio::transaction_header::ref_block_prefix;

variable max_net_usage_words

unsigned_int eosio::transaction_header::max_net_usage_words;

variable max_cpu_usage_ms

uint8_t eosio::transaction_header::max_cpu_usage_ms;

number of 8 byte words this transaction can serialize into after compressions

variable delay_sec

unsigned_int eosio::transaction_header::delay_sec;

number of CPU usage units to bill transaction for

variable context_free_actions

std::vector<action> eosio::transaction::context_free_actions;

variable actions

std::vector<action> eosio::transaction::actions;

variable transaction_extensions

extensions_type eosio::transaction::transaction_extensions;

variable sender_id

uint128_t eosio::onerror::sender_id;

variable sent_trx

std::vector<char> eosio::onerror::sent_trx;

Functions Documentation

function transaction_header

    time_point_sec exp = time_point_sec(now()+60)

Construct a new transaction_header object initialising the transaction header expiration to now + 60 seconds.

Construct a new transaction_header with an expiration of now + 60 seconds.

function transaction

    time_point_sec exp = time_point_sec(now()+60)

Construct a new transaction object initialising the transaction header expiration to now + 60 seconds.

Construct a new transaction with an expiration of now + 60 seconds.

function send

void eosio::transaction::send(
    const uint128_t & sender_id,
    name payer,
    bool replace_existing = false
) const

Writes the symbol_code as a string to the provided char buffer.

Sends this transaction, packs the transaction then sends it as a deferred transaction


  • sender_id - ID of sender
  • payer - Account paying for RAM
  • replace_existing - Defaults to false, if this is 0/false then if the provided sender_id is already in use by an in-flight transaction from this contract, which will be a failing assert. If 1 then transaction will atomically cancel/replace the inflight transaction

function from_current_action

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

Unpacks and returns a onerror struct.

from_current_action unpacks and returns a onerror struct

function unpack_sent_trx

transaction eosio::onerror::unpack_sent_trx() const

Unpacks and returns a transaction.

unpack_sent_trx unpacks and returns a transaction

function get_action

action eosio::get_action(
    uint32_t type,
    uint32_t index

Retrieve the indicated action from the active transaction.


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


the indicated action