Skip to content

otxn_field

  • Find the specified sf field in the originating transaction
  • Write the serialized version of the field to the output buffer
int64_t otxn_field (
uint32_t write_ptr,
uint32_t write_len,
uint32_t field_id
);
int64_t account_field_len =
otxn_field(account_field, 20, sfAccount);
NameTypeDescription
write_ptruint32_tPointer to a buffer of a suitable size to store the output.
write_lenuint32_tLength of the output buffer.
field_iduint32_t

The sf code of the field you are searching for.

To compute this manually take the serialized type and shift it into the 16 highest bits of uint32_t, then take the field and place it in the 16 lowest bits.

For example:
sfEmitNonce has type 5 and field 11 thus its value is 0x050BU

TypeDescription
int64_t

The 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 field

INVALID_FIELD
- the sf field_id was invalid

DOESNT_EXIST
- the field was not found in the originating transaction