Solana CookbookWallets
How to Create a Keypair
Any transaction on the Solana blockchain requires a vaid signature from the signing keypair or wallet. If you are connecting to a wallet, you do not need to worry about the keypair. Otherwise a keypair must be generated for signing transactions.
For most "signing" operations, you will need a KeyPairSigner
instance, which
can be used to sign transactions and messages. To generate a random
KeyPairSigner
:
TypeScript
import { generateKeyPairSigner } from "gill";// non-extractable and more secure keypairconst signer = await generateKeyPairSigner();console.log("address: ", signer.address);
Extractable keypair
Extractable keypairs are less secure and should not be used unless you
REALLY need to save the key for some reason. Since there are a few useful
cases for saving these keypairs, gill
contains a separate explicit function to
generate these extractable keypairs:
TypeScript
import { generateExtractableKeyPairSigner } from "gill";// extractable and less secure keypairconst extractableSigner = await generateExtractableKeyPairSigner();console.log("address: ", extractableSigner.address);
Is this page helpful?