V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 支持 Solana 登录

你可以在 V2EX 设置中绑定 Solana 地址,然后就可以用 Phantom / Glow 登录 V2EX。

Get V2EX Coin

9raUVuzeWUk53co63M4WXLWPWE4Xc6Lpn7RS9dnkpump

Sunyin
0D
0.01D
V2EX  ›  Solana

精打细算 - 转出所有的 solana 余额

  •  
  •   Sunyin · 4 天前 · 939 次点击

    初入币圈,Phantom OKX 都创建了钱包,但是有的钱包其实一直闲置着,偏偏会剩点零钱,使用钱包转出 sol 会留下 gas 费,我见不得不用的钱包里余额>0 ,很难受,所以研究了一下。

    记得先去回收代币租金!!! https://sol-incinerator.com/


    1. 操作环境

    看到有老哥 V 币被盗了,大家一定注意自己操作环境的安全

    系统环境:Ubuntu 24.04.2 LTS

    我这使用的是虚拟机,用完直接销毁了

    1.1. 安装 solana cli

    curl --proto '=https' --tlsv1.2 -sSfL https://solana-install.solana.workers.dev | bash
    

    1.2. 安装 base58

    钱包导出的私钥为 base58 ,需要转换

    sudo apt install python3-base58 -y
    

    验证一下

    root@ip-172-31-10-157:~# python3 -c "import base58;print(base58.b58decode('11111111111111111111111111111111'))"
    b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
    

    2. 操作

    绑定钱包

    将私钥转换,将WALLET_PRIVATE_KEY换成实际的私钥

    root@ip-172-31-10-157:~# python3 - <<'PY' <WALLET_PRIVATE_KEY> > ~/.config/solana/phantom.json
    import sys, json, base58
    b58 = sys.argv[1].strip()
    raw = base58.b58decode(b58)
    print(json.dumps(list(raw)))
    > PY
    

    结果

    root@ip-172-31-10-157:~# cat ~/.config/solana/phantom.json
    [165, 186, 96, ...]
    

    绑定密钥对

     solana config set --keypair ~/.config/solana/phantom.json
    

    设置为主网

    solana config set --url https://api.mainnet-beta.solana.com
    

    检查一下当前的配置

    solana config get
    
    Config File: /root/.config/solana/cli/config.yml
    RPC URL: https://api.mainnet-beta.solana.com
    WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
    Keypair Path: /root/.config/solana/phantom.json
    Commitment: confirmed
    

    然后就可以查看钱包地址和余额

    solana address # 地址
    solana balance # 余额
    

    转出

    注意将会消耗 0.000005sol 的手续费

    修改RECIPIENT_ADDRESS为目标钱包地址

    solana transfer <RECIPIENT_ADDRESS> $(echo "$(solana balance | tr -d ' SOL') - 0.000005" | bc -l) --from ~/.config/solana/phantom.json
    

    返回签名,即交易成功

    8 条回复    2025-09-28 08:51:34 +08:00
    deng1xia
        1
    deng1xia  
       4 天前
    回收租金用这个命令就行,spl-token close 代币地址
    Sunyin
        2
    Sunyin  
    OP
       4 天前
    @deng1xia sol-incinerator 是之前站长提到的工具 /t/1150712
    okx 钱包也有回收 solana 租金的功能


    不过我遇到过 okx 回收显示 2 个代币账户,sol-incinerator 中显示 3 个的情况,而且成功回收了 0.006sol
    所以默认就推荐了 sol-incinerator.com

    下次试试老哥的这个命令
    touzi
        3
    touzi  
    PRO
       4 天前
    不用搞这么复杂, 私钥导入 okx 钱包, 直接有回收功能. 资产全部转移到新的安全钱包.
    Sunyin
        4
    Sunyin  
    OP
       4 天前
    @touzi 浏览器插件和移动端 okx 都没有找到此功能,是 PC 端的功能么?
    touzi
        5
    touzi  
    PRO
       4 天前
    @Sunyin 手机端, 首页 - 更多 - Solana 租金回收
    Sunyin
        6
    Sunyin  
    OP
       4 天前 via iPhone
    @touzi 哦,这个只能回收代币租金,还会留下最后的一点 sol 在钱包。
    我这一套操作是为了不留一点 sol 转到别的钱包。
    Cedric341561
        7
    Cedric341561  
       2 天前   ❤️ 1
    可以直接填 ALL 的,不用这么麻烦
    USAGE:
    solana transfer [FLAGS] [OPTIONS] <RECIPIENT_ADDRESS> <AMOUNT>
    ARGS:
    <AMOUNT> The amount to send, in SOL; accepts keyword ALL
    Sunyin
        8
    Sunyin  
    OP
       1 天前
    @Cedric341561 感谢 学到了
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   933 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 19:39 · PVG 03:39 · LAX 12:39 · JFK 15:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.