> ## Documentation Index
> Fetch the complete documentation index at: https://docs.p2p.org/llms.txt
> Use this file to discover all available pages before exploring further.

# signWithKeypairs()

> Sign a Transaction using one or more keypairs.

This method accepts an unsigned transaction (or its base64-encoded representation) and a set of keypairs (or private keys) and signs the transaction with the keys.

Note that for the resulting transaction to be valid, you must provide the keys or keypairs corresponding to all the public keys that were originally passed when creating the transaction via [`stake()`](/docs/staking-sdk-solana-stake), [`withdraw()`](/docs/staking-sdk-solana-withdraw) or [`deactivate()`](/docs/staking-sdk-solana-deactivate).

<CodeGroup>
  ```javascript JavaScript theme={null}
  client.solana.signWithKeypairs(unsignedTx, [keypair1, keypair2]);
  ```
</CodeGroup>

<Warning>
  **This method is intended for testing purposes only.**

  Using this method requires passing private keys directly to the running code, which is often **not safe**. We strongly recommend signing transactions via dedicated software or hardware wallets, such as [Phantom](https://phantom.com/) or [Solflare](https://solflare.com/).
</Warning>

## Parameters

|                                                                                                                                                                                                                                                                                                                                                                                                    |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **unsignedTx** *Transaction or string, required*<br />The transaction that needs to be signed. Can be a Solana [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object or its base64-encoded representation. For a base64-encoded representation, the method will internally call [`decodeTransaction()`](/docs/staking-sdk-solana-decodetransaction). |
| **keypairs** *array, required*<br />An array of one or more keypairs to use for signing. Each element of the array must be a Solana [`Keypair`](https://solana-foundation.github.io/solana-web3.js/classes/Keypair.html) object or its private key represented as `Uint8Array` or `string`.                                                                                                        |

## Result

Returns a signed [`Transaction`](https://solana-foundation.github.io/solana-web3.js/classes/Transaction.html) object. If the method was called with an existing transaction object (not base64-encoded), all modifications will be done on that object, and the same object will be returned.

You can pass the signed transaction to [`verifyTransaction()`](/docs/staking-sdk-solana-verifytransaction) and [`sendTransaction()`](/docs/staking-sdk-solana-sendtransaction).


## Related topics

- [verifyTransaction()](/docs/staking-sdk-solana-verifytransaction.md)
- [sendTransaction()](/docs/staking-sdk-solana-sendtransaction.md)
- [Staking API reference](/reference/solana-staking-stake.md)
