提取多余 Lamport 的作用是什么?
WithdrawExcessLamports 将 Token
Program 账户中超出免租金最低要求的 SOL 转移至目标账户。代币余额和 mint 供应量不受影响——仅移动多余的 lamport。
此操作可回收此前无法使用的 SOL:发送至 token account、mint 或多签账户(均归属于 Token Program)的 lamport 原本无法被转移。
源码参考
账户
| 账户 | 描述 |
|---|---|
source | 可写。待提取的 token account、mint 或多签账户。 |
destination | 可写。接收多余 lamport 的账户。 |
authority | 根据源账户类型进行签名(见下文)。 |
签名权限
所需签名者取决于 source 账户的类型:
| 源账户类型 | 签名者 |
|---|---|
| Token account | token account 所有者(或其多签签名者)。 |
| 具有 mint authority 的 mint | mint authority。 |
| 不具有 mint authority 的 mint | mint account 本身必须签名(见下方说明)。 |
| 多签账户 | 已配置的 M-of-N 签名者。 |
"没有铸币权限的铸币"情况并不常见。当该情况适用时,铸币账户充当签名者:程序拥有的(曲线外)铸币通过其所属程序的 CPI 进行签名,而 keypair(曲线上)铸币则使用其密钥进行签名。
原生(wrapped SOL)token account 不受支持,将返回
NativeNotSupported。提款操作不能使源账户余额低于其免租最低要求。
如何提取多余的 lamport
此示例使用已配置的 @solana/kit
客户端——客户端设置请参阅转账代币。
Withdraw excess lamports (Kit)
import { getWithdrawExcessLamportsInstruction } from "@solana-program/token";// source/destination: addresses of the account to drain and the lamport recipient.// authority: a TransactionSigner that signs per the source account type.const instruction = getWithdrawExcessLamportsInstruction({source,destination,authority});await client.sendTransaction([instruction]);
对于多签权限,请通过 multiSigners 传入联合签名者。
Is this page helpful?