These docs are for v2.0. Click to read the latest docs for v3.0.

Serialize and output a slotted object

Behaviour

  • Serialize the object currently occupying the specified slot
  • Write the serialized version of the object to the output buffer

👍

Alternative use

For small objects you may avoid using a buffer. Specify 0, 0 for write_ptr, write_len to attempt to return the slotted object as big endian packed data in the int64_t return code. Up to 63 bits of data may be returned this way.

Definition

int64_t slot (
    uint32_t write_ptr,
    uint32_t write_len,
  	uint32_t slot_no
);

Example

uint8_t txn[512];
int64_t bytes_written = 
    slot(txn, 512, 1); // assumes a transaction is slotted into slot=1

Parameters

NameTypeDescription
write_ptruint32_tPointer to a buffer of a suitable size to store the output.
write_lenuint32_tLength of the output buffer.
slot_nouint32_tThe slot number

Return Code

TypeDescription
int64_tThe number of bytes written

If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.

TOO_SMALL
- output buffer was not large enough to hold the serialized object