How to Restore a Keypair or Signer

If you have an existing secret key, you can restore your Keypair from it. This allows you to access your wallet and sign transactions in your dApp.

Handle secret keys with care: never embed them in client-side code or commit them to source control. For backend services in production, use a key-management backend instead of a raw secret key — see Signing in Production.

From Bytes

import { createKeyPairSignerFromBytes } from "@solana/kit";
const keypairBytes = new Uint8Array([
174, 47, 154, 16, 202, 193, 206, 113, 199, 190, 53, 133, 169, 175, 31, 56,
222, 53, 138, 189, 224, 216, 117, 173, 10, 149, 53, 45, 73, 251, 237, 246, 15,
185, 186, 82, 177, 240, 148, 69, 241, 227, 167, 80, 141, 89, 240, 121, 121,
35, 172, 247, 68, 251, 226, 218, 48, 63, 176, 109, 168, 89, 238, 135,
]);
const signer = await createKeyPairSignerFromBytes(keypairBytes);
console.log(signer.address);
Console
Click to execute the code.

From Base58 String

import {
createKeyPairFromBytes,
createSignerFromKeyPair,
getBase58Encoder,
} from "@solana/kit";
const keypairBase58 =
"5MaiiCavjCmn9Hs1o3eznqDEhRwxo7pXiAYez7keQUviUkauRiTMD8DrESdrNjN8zd9mTmVhRvBJeg5vhyvgrAhG";
const keypair = await createKeyPairFromBytes(
getBase58Encoder().encode(keypairBase58),
);
const signer = await createSignerFromKeyPair(keypair);
console.log(signer.address);
Console
Click to execute the code.

Is this page helpful?

© 2026 Fundação Solana. Todos os direitos reservados.