• Creates a new KeyPairSigner from a 64-bytes Uint8Array secret key (private key and public key).

    Parameters

    • bytes: ReadonlyUint8Array<ArrayBufferLike>
    • Optionalextractable: boolean

    Returns Promise<KeyPairSigner>

    import 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.