Solana Keychain
Solana Keychain is a Solana Foundation library that gives you one signing interface across key-management backends: AWS KMS, GCP KMS, HashiCorp Vault, Privy, Turnkey, Fireblocks and others. It ships for TypeScript, Rust, Python and Go, at parity. The backend is chosen by config, so you can develop with an in-memory key and switch to a KMS or MPC custodian without rewriting call sites. All four SDKs are audited by OtterSec; the audit covers specific commits, listed in AUDIT_STATUS.md.
Contents
- When to use Keychain
- Packages
- Kit plugin client (TypeScript)
- Rust, Python, Go
- Gotchas
- Production rules
- Full documentation
When to use Keychain
Use Keychain for server-side signing: backend services, bots, AI agents with managed wallets, treasury and custodial apps, fee payers (including Kora nodes), and apps provisioning wallets for their users. It keeps raw keypair files off servers.
Keychain checks the signing hop, not the transaction. It does no simulation, content check or policy enforcement. Validate in your app (and simulate before signing, per the skill's guardrails), or use the provider's policy engine.
Packages
| Package | Version | Purpose |
|---|---|---|
solana-keychain (crates.io, PyPI) |
2.0.0 | Rust crate with one feature per backend; Python package with extras |
@solana/keychain |
2.0.0 | Umbrella: createKeychainSigner(config) plus all backend factories (createPrivySigner, …) |
@solana/keychain-core |
2.0.0 | Interfaces, SignerErrorCode, capability guards, signAndSendTransaction |
@solana/keychain-<backend> |
2.0.0 | One package per backend (-aws-kms, -vault, -turnkey, …). Install only the one you use |
@solana/keychain-kit-plugin |
2.0.0 | keychainSigner, keychainPayer, keychainIdentity Kit client plugins. Peer @solana/kit >=8.1.0 |
Every TypeScript signer except Crossmint and Fordefi native mode is a Kit TransactionPartialSigner. It signs transaction v1 (Fireblocks useProgramCall: true is the exception: legacy and v0 only).
Kit plugin client (TypeScript)
pnpm add @solana/keychain-kit-plugin @solana/kit @solana/kit-plugin-rpcimport { createClient, lamports } from '@solana/kit';
import { solanaRpc } from '@solana/kit-plugin-rpc';
import { keychainSigner } from '@solana/keychain-kit-plugin';
const rpcUrl = 'https://api.devnet.solana.com';
const client = await createClient()
.use(keychainSigner({
backend: 'aws-kms',
keyId: process.env.KMS_KEY_ID!,
publicKey: process.env.KMS_PUBLIC_KEY!, // base58 address of the KMS key
region: 'us-east-1',
}))
.use(solanaRpc({ rpcUrl, transactionConfig: { version: 1, priorityFeeLamports: lamports(5_000n) } }));
await client.sendTransaction([instruction]);- The signer plugin is async and must come before the RPC plugin, the same as every Kit signer plugin.
awaitthe final client. keychainSignersetspayerandidentityto the same signer.keychainPayerandkeychainIdentityset one role each and can use different backends, e.g. a KMS fee payer with a Turnkey authority.- Each plugin creates a new signer when it is applied. To share one signer across clients, create it once and install it with the standard signer plugin:
createClient().use(signer(await createKeychainSigner(config))). - Call
await client.payer.isAvailable()as a health check before relying on a remote backend. - Config is a tagged union on
backend:memory,vault,aws-kms,gcp-kms,privy,turnkey,fireblocks,cdp,crossmint,dfns,openfort,para,utila,fordefi. The fields for each backend are listed in the TypeScript guide.
Rust, Python, Go
- Rust:
cargo add solana-keychain, withdefault-features = falseplus the backend features you need. Pick exactly one ofsdk-v2(default),sdk-v3orsdk-v4. Transaction v1 needssdk-v4. Construct withSigner::from_*(e.g.Signer::from_aws_kms(...)) and reach the capability viaas_transaction_signer(). - Python:
pip install "solana-keychain[aws-kms]"(extras for backends that need a provider SDK;memory,vaultandparaneed none). Built onsolders; unified factorycreate_keychain_signer(backend, config). - Go: per-backend modules under
github.com/solana-foundation/solana-keychain/go/signers/<backend>/v2, built onsolana-gov2.
Gotchas
- Crossmint and Fordefi native mode can't be a client
payeroridentity. They rewrite or broadcast server-side, and the Kit plugins reject them at compile time and at runtime (SIGNER_CONFIG_ERROR). Create them withcreateKeychainSigner()instead:- Crossmint and Fordefi native auto (
chainset,pushModeomitted or'auto') are sending signers. Send withsignAndSendTransactionMessageWithSigners()from@solana/signers. - Fordefi native manual (
pushMode: 'manual') is a modifying signer.modifyAndSignTransactions()returns a rewritten transaction; broadcast that one yourself, never the one you passed in.
- Crossmint and Fordefi native auto (
SIGNER_BROADCAST_UNCONFIRMEDmeans the transaction may have landed. Reconcile with the provider before retrying (providerMayHaveAccepted(error)from@solana/keychain-core). Resending the byte-identical transaction is safe. A rebuilt transaction with a new blockhash is a second transfer.- Not every backend signs messages. Utila and Crossmint have no
signMessages, and CDP signs UTF-8 messages only. Narrow withisSolanaMessageSignerbefore calling it. - Swapping backends changes call sites only when the shape changes. Moving to or from Crossmint or Fordefi native mode changes the capability (sending or modifying signer instead of partial signer). Every other swap is config-only.
- Key rotation means a new address. The key is the address, so plan rotation as a migration of authorities and funds.
Production rules
- Separate hot signers (automated, low balance) from cold signers (treasury, MPC or HSM with approvals), and use distinct keys per environment.
- Grant least privilege. AWS KMS needs only
kms:Sign,kms:DescribeKeyandkms:GetPublicKeyon the specific key. Prefer IAM roles over static credentials. - Load provider secrets from a secret manager or env vars. Never hard-code or commit them, and never log key material.
- Retry sign-only failures with backoff. Don't blindly retry backends that broadcast (see
SIGNER_BROADCAST_UNCONFIRMED). - Monitor signing latency and failures, and turn on provider-side audit logs.
- Python and Go cannot zeroize key buffers, so treat process memory as sensitive with the
memorybackend. In Rust, never enable theunsafe-debugfeature in production.
Full list: production best practices.
Full documentation
Every page is served as Markdown. Fetch the .md URL for details beyond this file.
| Topic | URL |
|---|---|
| Overview | https://solana.com/docs/tools/keychain.md |
| TypeScript (per-backend config, Kit client, capabilities) | https://solana.com/docs/tools/keychain/getting-started/typescript.md |
| Rust | https://solana.com/docs/tools/keychain/getting-started/rust.md |
| Python | https://solana.com/docs/tools/keychain/getting-started/python.md |
| Go | https://solana.com/docs/tools/keychain/getting-started/go.md |
| Choosing a backend | https://solana.com/docs/tools/keychain/choosing-a-backend.md |
| Production best practices | https://solana.com/docs/tools/keychain/production-best-practices.md |
| Signing in production (concepts) | https://solana.com/docs/core/transactions/signing-in-production.md |
| Adding a backend | https://solana.com/docs/tools/keychain/adding-signers.md |
| Source | https://github.com/solana-foundation/solana-keychain |