pub fn get_field_optional<T: CurrentTxFieldGetter, const CODE: i32>(
field: SField<T, CODE>,
) -> Result<Option<T>>Expand description
Retrieves an optionally present field from the current transaction using an SField constant.
§Arguments
field- An SField constant that encodes both the field code and expected type
§Returns
Returns a Result<Option<T>> where:
Ok(Some(T))- The field value for the specified fieldOk(None)- If the field is not present (i.e., result_code == FIELD_NOT_FOUND)Err(Error)- If the field cannot be retrieved or has unexpected size
§Example
use xrpl_wasm_stdlib::core::current_tx::get_field_optional;
use xrpl_wasm_stdlib::sfield;
// Type is automatically inferred from the SField constant
let flags = get_field_optional(sfield::Flags).unwrap(); // Option<u32>
let source_tag = get_field_optional(sfield::SourceTag).unwrap(); // Option<u32>