Output the canonical hash of the originating transaction

Behaviour

  • Write the canonical hash of the originating transaction to the output buffer.
  • If flags = 1 and the transaction is an EMIT_FAILURE transaction then write the canonical hash of the originating transaction that caused the emission.

Definition

int64_t otxn_id (
    uint32_t write_ptr,
    uint32_t write_len,
    uint32_t flags
);

Example

uint8_t txn_id[32];
int64_t bytes_written = 
    otxn_id(txn_id, 32, 0);

Parameters

NameTypeDescription
write_ptruint32_tPointer to a buffer of to store the hash.
write_lenuint32_tLength of the output buffer. Should be at least 32 bytes.
flagsuint32_tIf 0:
Write the canonical hash of the originating transaction.

If 1 AND the originating transaction is an EMIT_FAILURE:
Write the canonical hash of the emitting transaction.

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