Transaction
Module: Contracts API
Type-safe C++ wrappers for transaction C API. More...
Classes
Name | |
---|---|
class | eosio::transaction_header Contains details about the transaction. |
class | eosio::transaction |
struct | eosio::onerror |
Types
Name | |
---|---|
typedef std::tuple< uint16_t, std::vector< char > > | extension |
typedef std::vector< extension > | extensions_type |
Functions
Name | |
---|---|
onerror | from_current_action() |
void | send_deferred(const uint128_t & sender_id, name payer, const char * serialized_transaction, size_t size, bool replace =false) |
action | get_action(uint32_t type, uint32_t index) |
size_t | read_transaction(char * ptr, size_t sz) |
int | cancel_deferred(const uint128_t & sender_id) |
size_t | transaction_size() |
int | tapos_block_num() |
int | tapos_block_prefix() |
uint32_t | expiration() Gets the expiration of the currently executing transaction. |
int | get_context_free_data(uint32_t index, char * buff, size_t size) |
Detailed Description
Type-safe C++ wrappers for transaction C API.
Note: There are some methods from the transactioncapi that can be used directly from C++
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.
Types 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 inline onerror from_current_action()
from_current_action unpacks and returns a onerror struct
function send_deferred
inline void send_deferred(
const uint128_t & sender_id,
name payer,
const char * serialized_transaction,
size_t size,
bool replace =false
)
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.
Send a deferred transaction
function get_action
inline action get_action(
uint32_t type,
uint32_t index
)
Parameters:
- type - 0 for context free action, 1 for action
- index - the index of the requested action
Return: the indicated action
Retrieve the indicated action from the active transaction.
function read_transaction
inline size_t read_transaction(
char * ptr,
size_t sz
)
Return: the currently executing transaction
Access a copy of the currently executing transaction.
function cancel_deferred
inline int cancel_deferred(
const uint128_t & sender_id
)
Parameters:
- sender_id - The id of the sender
Return: 1 if transaction was canceled, 0 if transaction was not found
Precondition:
- The deferred transaction ID exists.
- The deferred transaction ID has not yet been published.
Postcondition: Deferred transaction canceled.
Cancels a deferred transaction.
Example:
id = 0xffffffffffffffff
cancel_deferred( id );
function transaction_size
inline size_t transaction_size()
Return: size of the currently executing transaction
Gets the size of the currently executing transaction.
function tapos_block_num
inline int tapos_block_num()
Return: block number used for TAPOS on the currently executing transaction Example:
int tbn = tapos_block_num();
Gets the block number used for TAPOS on the currently executing transaction.
function tapos_block_prefix
inline int tapos_block_prefix()
Return: block prefix used for TAPOS on the currently executing transaction Example:
int tbp = tapos_block_prefix();
Gets the block prefix used for TAPOS on the currently executing transaction.
function expiration
inline uint32_t expiration()
Gets the expiration of the currently executing transaction.
Return: expiration of the currently executing transaction in seconds since Unix epoch
Gets the expiration of the currently executing transaction.
function get_context_free_data
inline int get_context_free_data(
uint32_t index,
char * buff,
size_t size
)
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
Return: size copied, or context_free_data[index].size() if 0 passed for size, or -1 if index not valid
Retrieve the signed_transaction.context_free_data[index].
Updated on 2022-12-05 at 15:38:07 +0000