pub struct TokenClient { /* private fields */ }Expand description
Token client for SPL token operations.
Implementations§
Source§impl TokenClient
impl TokenClient
pub fn new(rpc_url: &str, payer: Keypair) -> Self
Sourcepub async fn burn(
&self,
mint: &Pubkey,
token_account: &Pubkey,
amount: u64,
) -> Result<()>
pub async fn burn( &self, mint: &Pubkey, token_account: &Pubkey, amount: u64, ) -> Result<()>
Burn tokens from a token account.
Sourcepub async fn burn_and_close(
&self,
mint: &Pubkey,
token_account: &Pubkey,
amount: u64,
) -> Result<u64>
pub async fn burn_and_close( &self, mint: &Pubkey, token_account: &Pubkey, amount: u64, ) -> Result<u64>
Burn tokens and close the account if empty.
Sourcepub async fn transfer(
&self,
_mint: &Pubkey,
source: &Pubkey,
destination: &Pubkey,
amount: u64,
) -> Result<()>
pub async fn transfer( &self, _mint: &Pubkey, source: &Pubkey, destination: &Pubkey, amount: u64, ) -> Result<()>
Transfer tokens between accounts.
Sourcepub async fn create_associated_token_account(
&self,
wallet: &Pubkey,
mint: &Pubkey,
) -> Result<Pubkey>
pub async fn create_associated_token_account( &self, wallet: &Pubkey, mint: &Pubkey, ) -> Result<Pubkey>
Create an associated token account.
Sourcepub async fn get_or_create_ata(
&self,
wallet: &Pubkey,
mint: &Pubkey,
) -> Result<Pubkey>
pub async fn get_or_create_ata( &self, wallet: &Pubkey, mint: &Pubkey, ) -> Result<Pubkey>
Get or create associated token account.
Sourcepub async fn close_account(&self, token_account: &Pubkey) -> Result<u64>
pub async fn close_account(&self, token_account: &Pubkey) -> Result<u64>
Close a token account and recover rent.
Sourcepub async fn get_balance(&self, token_account: &Pubkey) -> Result<u64>
pub async fn get_balance(&self, token_account: &Pubkey) -> Result<u64>
Get token account balance.
Sourcepub async fn get_mint_info(&self, mint: &Pubkey) -> Result<MintInfo>
pub async fn get_mint_info(&self, mint: &Pubkey) -> Result<MintInfo>
Get mint info.
Auto Trait Implementations§
impl !Freeze for TokenClient
impl !RefUnwindSafe for TokenClient
impl !UnwindSafe for TokenClient
impl Send for TokenClient
impl Sync for TokenClient
impl Unpin for TokenClient
impl UnsafeUnpin for TokenClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more