Optionalextractable: booleanimport fs from 'fs';
import { createKeyPairSignerFromBytes } from '@solana/signers';
// Get bytes from local keypair file.
const keypairFile = fs.readFileSync('~/.config/solana/id.json');
const keypairBytes = new Uint8Array(JSON.parse(keypairFile.toString()));
// Create a KeyPairSigner from the bytes.
const signer = await createKeyPairSignerFromBytes(keypairBytes);
createKeyPairSignerFromPrivateKeyBytes if you only have the 32-bytes private key instead.
Creates a new KeyPairSigner from a 64-bytes
Uint8Arraysecret key (private key and public key).