Appearance
otxn_slot
Summary. Load the entire originating transaction into a slot, so its subfields and arrays can be navigated with the slot APIs.
Signature.
c
int64_t otxn_slot(uint32_t slot_no);Parameters.
| Name | Type | Description |
|---|---|---|
slot_no | uint32_t | Target slot number (1..255), or 0 to auto-allocate a free slot. |
Return value. Returns the slot number the transaction was loaded into (the same value you passed, or the auto-allocated one when you passed 0). Errors: INVALID_ARGUMENT (-7) if slot_no is greater than max_slots (255); NO_FREE_SLOTS (-6) if slot_no == 0 and no slot is free.
Common failure patterns.
- Passing a
slot_noabove 255 →INVALID_ARGUMENT. - Requesting auto-allocation (
0) when all 255 slots are in use →NO_FREE_SLOTS.
Caveats / notes.
- Loading into an occupied
slot_nooverwrites it. Pass0and use the returned number to avoid clobbering an existing slot. - Once slotted, use
slot_subfield/slot_subarrayto reach nested fields (e.g. an amount or a memo),slot_floatto read an amount as XFL, andslotto copy raw bytes out. This is the preferred route for structured or nested access, versus the flat serialization fromotxn_field. - During a failed-emit callback the slotted object is the emitted transaction (same
emitFailurerule as the rest of the family).
Minimal example.
c
int64_t slot_no = otxn_slot(0); // auto-allocate a slot for the whole txnPractical example.
c
// Load the originating transaction, expand its sfAmount subfield, and read
// it as an XFL floating value.
#define sfAmount ((6U << 16U) + 1U)
int64_t txn = otxn_slot(0);
if (txn < 0)
rollback(SBUF("could not slot otxn"), __LINE__);
if (slot_subfield(txn, sfAmount, 1) != 1)
rollback(SBUF("no Amount field"), __LINE__);
int64_t amt = slot_float(1); // XFL value of the amount
accept(SBUF("read amount"), 0);Related APIs. slot_subfield, slot_float, slot, meta_slot, otxn_field.