Transaction API
Defines C API for sending transactions and inline actions. More...
Functions
Detailed Description
Deferred transactions will not be processed until a future block. They can therefore have no effect on the success of failure of their parent transaction so long as they appear well formed. If any other condition causes the parent transaction to be marked as failing, then the deferred transaction will never be processed. Deferred transactions must adhere to the permissions available to the parent transaction or, in the future, delegated to the contract account for future use. 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.
Functions Documentation
function send_deferred
void send_deferred(
const uint128_t * sender_id,
capi_name payer,
const char * serialized_transaction,
size_t size,
uint32_t replace_existing
)
Sends a deferred transaction.
Parameters:
- sender_id - ID of sender
- payer - Account paying for RAM
- serialized_transaction - Pointer of serialized transaction to be deferred
- size - Size to reserve
- replace_existing - f this is
0
then if the provided sender_id is already in use by an in-flight transaction from this contract, which will be a failing assert. If1
then transaction will atomically cancel/replace the inflight transaction
function cancel_deferred
int cancel_deferred(
const uint128_t * sender_id
)
Cancels a deferred transaction.
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 read_transaction
size_t read_transaction(
char * buffer,
size_t size
)
Access a copy of the currently executing transaction.
Access a copy of the currently executing transaction.
Parameters:
- buffer - a buffer to write the current transaction to
- size - the size of the buffer, 0 to return required size
Returns:
the size of the transaction written to the buffer, or number of bytes that can be copied if size==0 passed
Access a copy of the currently executing transaction.
Returns:
the currently executing transaction
function transaction_size
size_t transaction_size(
void
)
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 tapos_block_num(
void
)
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 tapos_block_prefix(
void
)
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 expiration(
void
)
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 Example:
uint32_t tm = expiration();
eosio_print(tm);
Gets the expiration of the currently executing transaction.
Returns:
expiration of the currently executing transaction in seconds since Unix epoch
function get_action
int get_action(
uint32_t type,
uint32_t index,
char * buff,
size_t size
)
Retrieves the indicated action from the active transaction.
Retrieves the indicated action from the active transaction.
Parameters:
- type - 0 for context free action, 1 for action
- index - the index of the requested action
- buff - output packed buff of the action
- size - amount of buff read, pass 0 to have size returned
Returns:
the size of the action, -1 on failure
function get_context_free_data
int 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