Skip to main content

NFToken

Struct NFToken 

Source
#[repr(C)]
pub struct NFToken(pub [u8; 32]);
Expand description

Represents an NFToken (Non-Fungible Token) on the XRP Ledger.

The NFToken type wraps a 32-byte NFTokenID and provides methods to extract all fields encoded within the identifier, as well as retrieve associated metadata like the NFT’s URI.

§NFTokenID Encoding

The 32-byte identifier contains:

  • Bytes 0-1: Flags (16 bits, big-endian)
  • Bytes 2-3: Transfer fee (16 bits, big-endian, in 1/100,000 units)
  • Bytes 4-23: Issuer account address (160 bits)
  • Bytes 24-27: Scrambled taxon (32 bits, big-endian)
  • Bytes 28-31: Sequence number (32 bits, big-endian)

§Derived Traits

  • Copy: Efficient for this 32-byte struct, enabling implicit copying
  • PartialEq, Eq: Enable comparisons and use in collections
  • Debug, Clone: Standard traits for development and consistency

Tuple Fields§

§0: [u8; 32]

Implementations§

Source§

impl NFToken

Source

pub const fn new(id: [u8; 32]) -> Self

Creates a new NFToken from a 32-byte identifier.

§Arguments
  • id - The 32-byte NFTokenID
Source

pub const fn as_bytes(&self) -> &[u8; 32]

Returns the raw NFTokenID as a byte array.

Source

pub const fn as_ptr(&self) -> *const u8

Returns a pointer to the NFTokenID data.

This is primarily used internally for FFI calls to host functions.

Source

pub const fn len(&self) -> usize

Returns the length of the NFTokenID (always 32 bytes).

Source

pub fn flags(&self) -> Result<NftFlags>

Retrieves the flags associated with this NFToken.

Flags are stored in the first 2 bytes of the NFTokenID (big-endian).

§Returns
  • Ok(NftFlags) - A flags wrapper with helper methods
  • Err(Error) - If the host function fails
Source

pub fn transfer_fee(&self) -> Result<u16>

Retrieves the transfer fee for this NFToken.

The transfer fee is expressed in 1/100,000 units, meaning:

  • A value of 1 represents 0.001% (1/10 of a basis point)
  • A value of 100 represents 0.1% (10 basis points)
  • A value of 1000 represents 1% (100 basis points)
  • Maximum allowed value is 50,000 (representing 50%)
§Returns
  • Ok(u16) - The transfer fee (0-50,000)
  • Err(Error) - If the host function fails
Source

pub fn issuer(&self) -> Result<AccountID>

Retrieves the issuer account of this NFToken.

The issuer is encoded in bytes 4-23 of the NFTokenID (160 bits / 20 bytes).

§Returns
  • Ok(AccountID) - The issuer’s account identifier
  • Err(Error) - If the host function fails
Source

pub fn taxon(&self) -> Result<u32>

Retrieves the taxon of this NFToken.

The taxon is an issuer-defined value that groups related NFTs together.

§Returns
  • Ok(u32) - The taxon value
  • Err(Error) - If the host function fails
Source

pub fn token_sequence(&self) -> Result<u32>

Retrieves the token sequence number of this NFToken.

The token sequence number is automatically incremented for each NFToken minted by the issuer, based on the MintedNFTokens field of the issuer’s account. This ensures each NFToken has a unique identifier.

§Returns
  • Ok(u32) - The token sequence number
  • Err(Error) - If the host function fails
Source

pub fn uri(&self, owner: &AccountID) -> Result<UriBlob>

Retrieves the URI of this NFToken for a given owner.

§Arguments
  • owner - The account that owns this NFToken
§Returns
  • Ok(UriBlob) - The URI data (variable length, up to 256 bytes)
  • Err(Error) - If the NFT is not found or the host function fails

Trait Implementations§

Source§

impl AsRef<[u8]> for NFToken

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for NFToken

Source§

fn clone(&self) -> NFToken

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for NFToken

Source§

impl Debug for NFToken

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for NFToken

Source§

impl From<[u8; 32]> for NFToken

Source§

fn from(value: [u8; 32]) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for NFToken

Source§

fn eq(&self, other: &NFToken) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NFToken

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.