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
[writable]The source account.[]The token mint.[writable]The destination account.[signer]The source account’s owner/delegate.
- Multisignature owner/delegate
[writable]The source account.[]The token mint.[writable]The destination account.[]The source account’s multisignature owner/delegate...+M[signer]M signer accounts.
Fields§
§from: &'account AccountViewThe source account.
mint: &'account AccountViewThe token mint.
to: &'account AccountViewThe destination account.
The source account’s owner/delegate.
multisig_signers: &'multisig [MultisigSigner]Multisignature signers.
amount: u64The amount of tokens to transfer.
decimals: u8Expected number of base 10 digits to the right of the decimal place.
Implementations§
Source§impl<'account> TransferChecked<'account, '_, &'account AccountView>
impl<'account> TransferChecked<'account, '_, &'account AccountView>
Sourcepub const DISCRIMINATOR: u8 = 12
pub const DISCRIMINATOR: u8 = 12
The instruction discriminator.
Sourcepub const MAX_ACCOUNTS_LEN: usize
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.
Sourcepub const DATA_LEN: usize = 10
pub const DATA_LEN: usize = 10
Instruction data length:
- discriminator (1 byte)
- amount (8 bytes)
- decimals (1 byte)
Sourcepub fn new(
from: &'account AccountView,
mint: &'account AccountView,
to: &'account AccountView,
authority: &'account AccountView,
amount: u64,
decimals: u8,
) -> Self
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>
impl<'account, 'multisig, MultisigSigner: AsRef<AccountView>> TransferChecked<'account, 'multisig, MultisigSigner>
Sourcepub 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
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.
pub fn invoke(&self) -> ProgramResult
pub fn invoke_signed(&self, signers: &[Signer<'_, '_>]) -> ProgramResult
Trait Implementations§
Source§impl<MultisigSigner: AsRef<AccountView>> CpiWriter for TransferChecked<'_, '_, MultisigSigner>
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,
fn write_accounts<'cpi>(
&self,
accounts: &mut [MaybeUninit<CpiAccount<'cpi>>],
) -> Result<usize, ProgramError>where
Self: 'cpi,
AccountViews required by this instruction into the provided
slice. Read moreSource§fn write_instruction_accounts<'cpi>(
&self,
accounts: &mut [MaybeUninit<InstructionAccount<'cpi>>],
) -> Result<usize, ProgramError>where
Self: 'cpi,
fn write_instruction_accounts<'cpi>(
&self,
accounts: &mut [MaybeUninit<InstructionAccount<'cpi>>],
) -> Result<usize, ProgramError>where
Self: 'cpi,
InstructionAccounts required by this instruction into the
provided slice. Read moreSource§fn write_instruction_data(
&self,
data: &mut [MaybeUninit<u8>],
) -> Result<usize, ProgramError>
fn write_instruction_data( &self, data: &mut [MaybeUninit<u8>], ) -> Result<usize, ProgramError>
Source§impl<MultisigSigner: AsRef<AccountView>> IntoBatch for TransferChecked<'_, '_, MultisigSigner>
impl<MultisigSigner: AsRef<AccountView>> IntoBatch for TransferChecked<'_, '_, MultisigSigner>
Source§fn into_batch<'account, 'state>(
self,
batch: &mut Batch<'account, 'state>,
) -> ProgramResultwhere
Self: 'account + 'state,
fn into_batch<'account, 'state>(
self,
batch: &mut Batch<'account, 'state>,
) -> ProgramResultwhere
Self: 'account + 'state,
self into the provided batch.