Skip to main content

get_field

Function get_field 

Source
pub fn get_field<T: CurrentTxFieldGetter, const CODE: i32>(
    field: SField<T, CODE>,
) -> Result<T>
Expand description

Retrieves a 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<T> where:

  • Ok(T) - The field value for the specified field
  • Err(Error) - If the field cannot be retrieved or has unexpected size

§Example

use xrpl_wasm_stdlib::core::current_tx::get_field;
use xrpl_wasm_stdlib::sfield;

// Type is automatically inferred from the SField constant
let sequence = get_field(sfield::Sequence).unwrap();  // u32
let account = get_field(sfield::Account).unwrap();  // AccountID