import { generateKeyPair } from '@solana/keys';
import { signTransaction } from '@solana/transactions';
const signedTransaction = await signTransaction([myPrivateKey], tx);
partiallySignTransaction if you want to sign the transaction without asserting that the resulting transaction is fully signed.
Given an array of
CryptoKeyobjects which are private keys pertaining to addresses that are required to sign a transaction, this method will return a new signed transaction of type FullySignedTransaction.This function will throw unless the resulting transaction is fully signed.