Cosa fa Scartare Lamport?
UnwrapLamports sposta SOL fuori da un token account nativo (SOL avvolto)
verso un account di destinazione come lamport. Puoi scartare l'intero saldo o un
importo specifico, e il token account rimane aperto.
Questo è più flessibile della chiusura di un account SOL avvolto: uno scarto parziale consente di prelevare una parte di SOL mantenendo l'account finanziato per un uso futuro.
Riferimento al Codice Sorgente
| Elemento | Descrizione | Sorgente |
|---|---|---|
UnwrapLamports | L'istruzione (discriminatore 45). | Sorgente |
process_unwrap_lamports | Logica del processore. | Sorgente |
Account
| Account | Descrizione |
|---|---|
source | Scrivibile. Il token account nativo (SOL avvolto) da scartare. |
destination | Scrivibile. Riceve i lamport scartati. |
authority | Il proprietario dell'account o un delegato (o firmatari multisig). |
La sorgente deve essere un token account nativo; altri token account
restituiscono NonNativeNotSupported. Un delegato può scartare fino
all'importo delegatogli.
Come Scartare Lamport
Ometti amount per scartare l'intero saldo, oppure impostalo per scartare
un numero specifico di lamport. L'esempio utilizza un client
@solana/kit configurato —
consulta Trasferire Token per la
configurazione del client.
import { getUnwrapLamportsInstruction } from "@solana-program/token";// source: the native (wrapped SOL) token account to unwrap.// destination: address that receives the unwrapped lamports.// authority: a TransactionSigner (the account owner or a delegate).// Unwrap a specific number of lamports.const unwrapSome = getUnwrapLamportsInstruction({source,destination,authority,amount: 500_000_000n});// Or omit `amount` to unwrap the entire balance.const unwrapAll = getUnwrapLamportsInstruction({source,destination,authority});// Send whichever instruction you need.await client.sendTransaction([unwrapSome]);
Per un'autorità multisig, passa i co-firmatari con multiSigners.
Is this page helpful?