solana-wallets-vue icon indicating copy to clipboard operation
solana-wallets-vue copied to clipboard

signTransaction() not worked, error as "WalletSignTransactionError: Expected String"

Open jackalchenxu opened this issue 2 years ago • 4 comments

Hello, lorisleiva, thanks for your great work.

i'm now trying use solana-wallets-vue with Vue3 and make a simple test, like the sample code; wallet software is Phantom, installed as Chrome plugin; wallet is changed to use your lib.

the sample code is like below:

import { useWallet }  from `solana-wallets-vue`;
import { Connection, Transaction } from `@solana/web3.js`;
...
const { wallet, publicKey }  = useWallet();
...
let transaction = new Transaction().add(
  SystemProgram.transfer({
    fromPubkey: wallet.publicKey,
    toPubkey: wallet.publicKey,
    lamports: 100,
  })
);
let { blockhash } = await connection.getRecentBlockhash();
transaction.recentBlockhash = blockhash;
transaction.feePayer = wallet.publicKey;
let signed = await wallet.signTransaction(transaction);
let txid = await connection.sendRawTransaction(signed.serialize());
await connection.confirmTransaction(txid);

the error occurs at let signed = await wallet.signTransaction(transaction);, the error message as: WalletSignTransactionError: Expected String at PhantomWalletAdatapter,signTransaction

i trace the code, and under the hood, the code shows wallet need its secretkey to sign a transaction, but all know, the wallet doesn't expose the secretkey.

if we change the above sample code, not sign the transaction, but directly sendTransaction(...), it will work! (sendTransaction will still partialsignTransaction, but in itself inner implementation of wallet code)

Here is my question:

  • am i missing something that makes signTransaction not work?

if you need the full code to reproduce the issue , please comment.

jackalchenxu avatar Aug 16 '22 03:08 jackalchenxu

Recently there have been lots of errors on the phantom side of solana. While using wallet.sendTransaction() it shows "Missing or Invalid Parameters" with a long stack trace leading back to solana-wallets-vue... I feel this is related so I decided to drop it here....

And I tried the adapters on react and it worked so...

Psionyc avatar Aug 28 '22 10:08 Psionyc

Yep facing the same issue here. I've tried updating the dependencies but without a guide on how to contribute to the project, it's hard. I'm unable to test the package properly, as I also can't get a fork to simply compile.

Aanhane avatar Aug 29 '22 10:08 Aanhane

So after trying somethings I found out wallet.signTransaction.value works and the transaction is signed for all wallets... While checking why the error might have occured with wallet.sendTransaction I found out that in the phantom wallet adapter code the function is named signAndSendTransaction() which might be the overall cause of the error...

Psionyc avatar Aug 31 '22 10:08 Psionyc

Maybe the SendOptions is required for wallet.sendTransaction method. Initialize connection with commitmentOrConfig works. const connection = new Connection(clusterApiUrl('devnet'), 'confirmed').

hsienfu avatar Sep 04 '22 00:09 hsienfu