Giải Nén Lamports

Giải Nén Lamports Làm Gì?

UnwrapLamports chuyển SOL ra khỏi token account gốc (wrapped SOL) vào một tài khoản đích dưới dạng lamport. Bạn có thể giải nén toàn bộ số dư hoặc một số lượng cụ thể, và token account vẫn được giữ nguyên.

Điều này linh hoạt hơn so với việc đóng một tài khoản wrapped SOL: giải nén một phần cho phép bạn rút một lượng SOL nhất định trong khi vẫn giữ tài khoản có số dư để sử dụng sau.

Tham Chiếu Nguồn

MụcMô tảNguồn
UnwrapLamportsLệnh (discriminator 45).Nguồn
process_unwrap_lamportsLogic xử lý.Nguồn

Tài Khoản

Tài khoảnMô tả
sourceCó thể ghi. token account gốc (wrapped SOL) cần giải nén.
destinationCó thể ghi. Nhận các lamport đã giải nén.
authorityChủ sở hữu tài khoản hoặc một đại biểu (hoặc các người ký multisig).

Nguồn phải là một native token account; các token account khác sẽ trả về NonNativeNotSupported. Một đại biểu có thể giải nén tối đa số lượng được ủy quyền.

Cách Giải Nén Lamports

Bỏ qua amount để giải nén toàn bộ số dư, hoặc đặt giá trị để giải nén một số lamport cụ thể. Ví dụ sử dụng client @solana/kit đã được cấu hình — xem Chuyển Token để thiết lập client.

Unwrap wrapped SOL (Kit)
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]);

Đối với quyền multisig, hãy truyền các người ký đồng thuận với multiSigners.

Is this page helpful?

Mục lục

Chỉnh sửa trang