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(), withdraw() or deactivate().

client.solana.signWithKeypairs(unsignedTx, [keypair1, keypair2]);
❗️

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 or Solflare.

Parameters

unsignedTx Transaction or string, required
The transaction that needs to be signed. Can be a Solana Transaction object or its base64-encoded representation. For a base64-encoded representation, the method will internally call decodeTransaction().

keypairs array, required
An array of one or more keypairs to use for signing. Each element of the array must be a Solana Keypair object or its private key represented as Uint8Array or string.

Result

Returns a signed Transaction 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() and sendTransaction().

What's next?