Skip to main content

SplTokenAccount

Struct SplTokenAccount 

Source
#[repr(C)]
pub struct SplTokenAccount { pub mint: [u8; 32], pub owner: [u8; 32], pub amount: [u8; 8], pub delegate_tag: [u8; 4], pub delegate: [u8; 32], pub state: u8, pub is_native_tag: [u8; 4], pub native_amount: [u8; 8], pub delegated_amount: [u8; 8], pub close_authority_tag: [u8; 4], pub close_authority: [u8; 32], }
Expand description

Zero-copy overlay for an SPL Token account (165 bytes).

Layout:

  0..32   mint           [u8; 32]
 32..64   owner          [u8; 32]
 64..72   amount         [u8; 8]   (u64 LE)
 72..76   delegate_tag   [u8; 4]   (u32 LE: 0=None, 1=Some)
 76..108  delegate       [u8; 32]
108..109  state          u8        (0=uninit, 1=init, 2=frozen)
109..113  is_native_tag  [u8; 4]   (u32 LE: 0=None, 1=Some)
113..121  native_amount  [u8; 8]   (u64 LE)
121..129  delegated_amt  [u8; 8]   (u64 LE)
129..133  close_auth_tag [u8; 4]   (u32 LE: 0=None, 1=Some)
133..165  close_auth     [u8; 32]

Fields§

§mint: [u8; 32]

Mint address associated with this token account.

§owner: [u8; 32]

Owner of this token account.

§amount: [u8; 8]

Token balance (u64 LE).

§delegate_tag: [u8; 4]

Delegate option tag (u32 LE: 0=None, 1=Some).

§delegate: [u8; 32]

Delegate address (valid only if delegate_tag == 1).

§state: u8

Account state: 0=Uninitialized, 1=Initialized, 2=Frozen.

§is_native_tag: [u8; 4]

Is-native option tag (u32 LE).

§native_amount: [u8; 8]

Native SOL amount (u64 LE, valid only if is_native_tag == 1).

§delegated_amount: [u8; 8]

Delegated amount (u64 LE).

§close_authority_tag: [u8; 4]

Close authority option tag (u32 LE).

§close_authority: [u8; 32]

Close authority address (valid only if close_authority_tag == 1).

Implementations§

Source§

impl SplTokenAccount

Source

pub fn amount(&self) -> u64

Read the token amount as a u64.

Source

pub fn has_delegate(&self) -> bool

Check whether a delegate is set.

Source

pub fn is_native(&self) -> bool

Check whether this is a native (SOL-wrapped) token account.

Source

pub fn has_close_authority(&self) -> bool

Check whether a close authority is set.

Source

pub fn is_initialized(&self) -> bool

Check if the account is initialized.

Source

pub fn is_frozen(&self) -> bool

Check if the account is frozen.

Trait Implementations§

Source§

impl Clone for SplTokenAccount

Source§

fn clone(&self) -> SplTokenAccount

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl FixedLayout for SplTokenAccount

Source§

const SIZE: usize = 165

The exact byte size of this type on-chain.
Source§

impl Copy for SplTokenAccount

Source§

impl Pod for SplTokenAccount

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
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.