#[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 copyingPartialEq, Eq: Enable comparisons and use in collectionsDebug, Clone: Standard traits for development and consistency
Tuple Fields§
§0: [u8; 32]Implementations§
Source§impl NFToken
impl NFToken
Sourcepub const fn as_ptr(&self) -> *const u8
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.
Sourcepub fn flags(&self) -> Result<NftFlags>
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 methodsErr(Error)- If the host function fails
Sourcepub fn transfer_fee(&self) -> Result<u16>
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
Sourcepub fn issuer(&self) -> Result<AccountID>
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 identifierErr(Error)- If the host function fails
Sourcepub fn taxon(&self) -> Result<u32>
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 valueErr(Error)- If the host function fails
Sourcepub fn token_sequence(&self) -> Result<u32>
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 numberErr(Error)- If the host function fails