transfer_spltoken
Transfers an SPL Token from the user's wallet to another wallet address.
_33use mirrorworld_sdk_rust::{ transfer_spltoken };_33_33fn main() {_33_33 // In this example, we shall transfer USDC 1000 SPL_33 // to this wallet address: 2BrLoxPTkPLyLuD3sPitNKXQRA9y8zzZ9P6vYwMTtgBL_33_33 // See USDC in the Solana explorer: https://explorer.solana.com/address/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v_33_33_33 let recipient_public_key: &str = "2BrLoxPTkPLyLuD3sPitNKXQRA9y8zzZ9P6vYwMTtgBL";_33 let amount: &str = "1000";_33 let token_mint_address: &str = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";_33 let token_decimals: &str = "6";_33_33 let result: TransferSpltoken = transfer_spltoken(recipient, amount).await?;_33}_33_33// Return Types_33// ============_33_33 #[derive(Debug, Serialize, Deserialize)]_33pub struct TransferSpltoken {_33 pub tx_signature: String_33}_33_33// Error response if any_33// =====================_33#[derive(Debug, Serialize, Deserialize)]_33pub struct Err {_33 #[serde(rename = "InstructionError")]_33 pub instruction_error: Option<String>,_33}
Edit this page on GitHub