Skip to main content

TransferChecked

Struct TransferChecked 

Source
pub struct TransferChecked<'account, 'multisig, MultisigSigner: AsRef<AccountView>> {
    pub from: &'account AccountView,
    pub mint: &'account AccountView,
    pub to: &'account AccountView,
    pub authority: &'account AccountView,
    pub multisig_signers: &'multisig [MultisigSigner],
    pub amount: u64,
    pub decimals: u8,
}
Expand description

Transfers tokens from one account to another either directly or via a delegate. If this account is associated with the native mint then equal amounts of SOL and Tokens will be transferred to the destination account.

This instruction differs from super::Transfer in that the token mint and decimals value is checked by the caller. This may be useful when creating transactions offline or within a hardware wallet.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The source account.
  2. [] The token mint.
  3. [writable] The destination account.
  4. [signer] The source account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The source account.
  2. [] The token mint.
  3. [writable] The destination account.
  4. [] The source account’s multisignature owner/delegate.
  5. ..+M [signer] M signer accounts.

Fields§

§from: &'account AccountView

The source account.

§mint: &'account AccountView

The token mint.

§to: &'account AccountView

The destination account.

§authority: &'account AccountView

The source account’s owner/delegate.

§multisig_signers: &'multisig [MultisigSigner]

Multisignature signers.

§amount: u64

The amount of tokens to transfer.

§decimals: u8

Expected number of base 10 digits to the right of the decimal place.

Implementations§

Source§

impl<'account> TransferChecked<'account, '_, &'account AccountView>

Source

pub const DISCRIMINATOR: u8 = 12

The instruction discriminator.

Source

pub const MAX_ACCOUNTS_LEN: usize

Maximum number of accounts expected by this instruction.

The required number of accounts will depend whether the source account has a single owner or a multisignature owner.

Source

pub const DATA_LEN: usize = 10

Instruction data length:

  • discriminator (1 byte)
  • amount (8 bytes)
  • decimals (1 byte)
Source

pub fn new( from: &'account AccountView, mint: &'account AccountView, to: &'account AccountView, authority: &'account AccountView, amount: u64, decimals: u8, ) -> Self

Creates a new TransferChecked instruction with a single owner/delegate authority.

Source§

impl<'account, 'multisig, MultisigSigner: AsRef<AccountView>> TransferChecked<'account, 'multisig, MultisigSigner>

Source

pub fn with_multisig_signers( from: &'account AccountView, mint: &'account AccountView, to: &'account AccountView, authority: &'account AccountView, amount: u64, decimals: u8, multisig_signers: &'multisig [MultisigSigner], ) -> Self

Creates a new TransferChecked instruction with a multisignature owner/delegate authority and signer accounts.

Source

pub fn invoke(&self) -> ProgramResult

Source

pub fn invoke_signed(&self, signers: &[Signer<'_, '_>]) -> ProgramResult

Trait Implementations§

Source§

impl<MultisigSigner: AsRef<AccountView>> CpiWriter for TransferChecked<'_, '_, MultisigSigner>

Source§

fn write_accounts<'cpi>( &self, accounts: &mut [MaybeUninit<CpiAccount<'cpi>>], ) -> Result<usize, ProgramError>
where Self: 'cpi,

Writes the AccountViews required by this instruction into the provided slice. Read more
Source§

fn write_instruction_accounts<'cpi>( &self, accounts: &mut [MaybeUninit<InstructionAccount<'cpi>>], ) -> Result<usize, ProgramError>
where Self: 'cpi,

Writes the InstructionAccounts required by this instruction into the provided slice. Read more
Source§

fn write_instruction_data( &self, data: &mut [MaybeUninit<u8>], ) -> Result<usize, ProgramError>

Writes the instruction data for this instruction into the provided slice. Read more
Source§

impl<MultisigSigner: AsRef<AccountView>> IntoBatch for TransferChecked<'_, '_, MultisigSigner>

Source§

fn into_batch<'account, 'state>( self, batch: &mut Batch<'account, 'state>, ) -> ProgramResult
where Self: 'account + 'state,

Serializes self into the provided batch.

Auto Trait Implementations§

§

impl<'account, 'multisig, MultisigSigner> Freeze for TransferChecked<'account, 'multisig, MultisigSigner>

§

impl<'account, 'multisig, MultisigSigner> RefUnwindSafe for TransferChecked<'account, 'multisig, MultisigSigner>
where MultisigSigner: RefUnwindSafe,

§

impl<'account, 'multisig, MultisigSigner> !Send for TransferChecked<'account, 'multisig, MultisigSigner>

§

impl<'account, 'multisig, MultisigSigner> !Sync for TransferChecked<'account, 'multisig, MultisigSigner>

§

impl<'account, 'multisig, MultisigSigner> Unpin for TransferChecked<'account, 'multisig, MultisigSigner>

§

impl<'account, 'multisig, MultisigSigner> UnsafeUnpin for TransferChecked<'account, 'multisig, MultisigSigner>

§

impl<'account, 'multisig, MultisigSigner> UnwindSafe for TransferChecked<'account, 'multisig, MultisigSigner>
where MultisigSigner: RefUnwindSafe,

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> 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, 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.