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

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

Get V2EX Coin

9raUVuzeWUk53co63M4WXLWPWE4Xc6Lpn7RS9dnkpump

renfei
V2EX  ›  Solana

Ledger 的 Solana 目前无法 signMessage,绑定逻辑是否可以增加一种:交易 + Memo 来替代

  •  
  •   renfei · 26 天前 · 712 次点击

    Ledger 的 Solana 目前无法 signMessage

    参见官方文档: https://support.ledger.com/article/Unable-to-sign-off-chain-Message-with-Ledger-Solana-wallet-created-in-third-party-wallets

    GitHub: https://github.com/LedgerHQ/ledger-live/issues/11239

    从很久就是已知问题了,但官方目前只能保证交易签名是稳定的。这就导致 Ledger 用户无法在 V 站绑定

    交易 + Memo 替代

    原理

    • 构造一笔 0 SOL 转账交易( from → from ,自转账);
    • 在交易里附加 Memo 程序指令,把你要签的消息放进去;
    • 用户用 Ledger 签这笔交易;
    • 后端拿到交易签名、解码 Memo ,验证签名是否匹配用户公钥。

    前端示例( JavaScript + @solana/web3.js + Wallet Adapter )

    import {
      Connection,
      PublicKey,
      Transaction,
      SystemProgram,
    } from '@solana/web3.js';
    import { WalletNotConnectedError } from '@solana/wallet-adapter-base';
    import { WalletAdapterNetwork } from '@solana/wallet-adapter-base';
    import { MemoProgram } from '@solana/spl-memo';
    
    async function signMessageWithMemo(wallet, message) {
      if (!wallet.publicKey) throw new WalletNotConnectedError();
    
      const connection = new Connection('https://api.mainnet-beta.solana.com');
    
      // 构造交易:0 SOL 自转账 + Memo
      const transaction = new Transaction().add(
        SystemProgram.transfer({
          fromPubkey: wallet.publicKey,
          toPubkey: wallet.publicKey,
          lamports: 0,
        }),
        MemoProgram.memo({ memo: message }) // 将你的消息放入 Memo
      );
    
      // 请求用户签名
      const signedTransaction = await wallet.signTransaction(transaction);
    
      // 序列化为 base64 或 hex ,发送给后端
      const serialized = signedTransaction.serialize().toString('base64');
      return serialized;
    }
    

    站长是否考虑一下?要不然 Ledger 用户就只能干等了

    4 条回复    2025-08-16 21:36:30 +08:00
    renfei
        1
    renfei  
    OP
       26 天前
    忘记 @Livid 站长大大了,考虑一下不🙏
    Livid
        2
    Livid  
    MOD
    PRO
       25 天前
    @renfei 我想想……

    那么,如果你用 Ledger 操作现在 V2EX 的打赏流程(打赏流程目前不要求绑定钱包),能完成吗?
    renfei
        3
    renfei  
    OP
       25 天前
    Livid
        4
    Livid  
    MOD
    PRO
       25 天前
    @renfei 感谢确认。那一种可能的实现方式是,在打赏的时候,提供一个可选项,将打赏地址和当前 cookie 账号绑定。
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3035 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:15 · PVG 20:15 · LAX 05:15 · JFK 08:15
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.