Skip to content

xpop_slot

  • Locate the XPOP on the originating Import transaction and extract its inner transaction and metadata.
  • Place the transaction into slot_no_tx and the metadata into slot_no_meta.
  • A slot argument of 0 asks the host to allocate a free slot. A nonzero argument must be 1..255 and is overwritten if it already holds an object.
  • Two nonzero arguments must name different slots.
  • On success, returns both slot numbers packed into one value: (tx_slot << 16) | meta_slot.
int64_t xpop_slot (
uint32_t slot_no_tx,
uint32_t slot_no_meta
);
int64_t slots = xpop_slot(0, 0); // let the host allocate both slots
if (slots < 0)
rollback(SBUF("No XPOP"), 1);
uint32_t tx_slot = (uint32_t)(slots >> 16);
uint32_t meta_slot = (uint32_t)(slots & 0xFFFF);
NameTypeDescription
slot_no_txuint32_tSlot to receive the XPOP’s inner transaction: 0 to allocate one, or 1..255.
slot_no_metauint32_tSlot to receive the XPOP’s metadata: 0 to allocate one, or 1..255. Must differ from a nonzero slot_no_tx.
TypeDescription
int64_t

On success, (tx_slot << 16) | meta_slot: the transaction slot in the upper 16 bits and the metadata slot in the lower 16 bits.

If negative, an error:

PREREQUISITE_NOT_MET
- The originating transaction is not an Import.

INVALID_ARGUMENT
- A slot number is above 255, or both slot numbers name the same nonzero slot.

NO_FREE_SLOTS
- A slot had to be allocated but the Hook already uses the maximum number of slots.

INVALID_TXN
- The Import does not carry a readable inner transaction and metadata.