anza-xyz / wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
https://anza-xyz.github.io/wallet-adapter/
Apache License 2.0
1.44k stars 906 forks source link

Pass the krypair of backend wallet as a Signer for the transaction #974

Closed umaid56 closed 1 month ago

umaid56 commented 1 month ago

I want to sign the transaction using both a keypair as a backend wallet and the Phantom wallet. I am using the Solana wallet adapter package. How can I do this with the Solana wallet adapter and the backend keypair? I was using this but it can't work as it give me error

Error: transaction.serialize is not a function at StandardWalletAdapter.sendTransaction (adapter.ts:347:1)

 const backend = Keypair.fromSecretKey( base58.decode(keypair ) );

const ExecuteInstructions = await constructExecuteSaleTxByBuyer(wallet?.adapter,publicKey,sellerPubKey,mintAddress,1)
      ExecuteInstructions.recentBlockhash = (
    await connection.getLatestBlockhash()
     ).blockhash;
    ExecuteInstructions.feePayer = publicKey

    ExecuteInstructions.sign(backend);
    const serializedTx = ExecuteInstructions.serialize({ requireAllSignatures: false });
    const ExecuteSignature = await sendTransaction(serializedTx, connection);
    await connection.confirmTransaction(ExecuteSignature);
    console.log("\n\n\n\nExecution Done",ExecuteSignature)