> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# How to Sign with a Keychain Backend

> Sign Solana transactions through a key-management backend using @solana/keychain, so you can swap most signing providers without changing code.

[Keychain](/developers/docs/tools/keychain) provides one `SolanaSigner` interface across
many key-management backends: in-memory keys, cloud KMS/HSM, and managed wallet
services. Write your signing code once, then switch backends through
configuration.

The example below signs and sends a transfer with an in-memory signer. The same
code works with any backend that signs a transaction you own (most of them);
only the signer's construction changes. Crossmint and Fordefi native modes
rewrite or broadcast the transaction themselves, so they cannot act as a Kit
client signer: call them through `signAndSendTransaction()` from
`@solana/keychain-core` instead.

```ts Kit
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";
import { createMemorySigner } from "@solana/keychain-memory";
import { rpcAirdrop, solanaRpc } from "@solana/kit-plugin-rpc";
import { airdropSigner, signer } from "@solana/kit-plugin-signer";
import { getTransferSolInstruction } from "@solana-program/system";

// Most Keychain backends return a `SolanaTransactionSigner`. Swap this
// in-memory signer for `createAwsKmsSigner`, `createVaultSigner`, ... and the
// rest of this file is identical.
const keychainSigner = await createMemorySigner({
  privateKey: crypto.getRandomValues(new Uint8Array(32)),
});

const recipient = await generateKeyPairSigner();

const client = await createClient()
  .use(signer(keychainSigner))
  .use(
    solanaRpc({
      rpcUrl: "http://localhost:8899",
      rpcSubscriptionsUrl: "ws://localhost:8900",
    }),
  )
  .use(rpcAirdrop())
  .use(airdropSigner(lamports(1_000_000_000n)));

const { context } = await client.sendTransaction([
  getTransferSolInstruction({
    source: keychainSigner,
    destination: recipient.address,
    amount: lamports(10_000_000n),
  }),
]);

console.log("Signature:", context.signature);
```

<div className="sol-run" data-run="cookbook/wallets/sign-with-keychain/sign" data-tab="Kit">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Output from a local Surfpool network</span></div>
<div className="sol-run-out">

```text Output
Signature: 3obsAgnYbB9ZygL8KBrWqW6faFa3MvWM2D5NfmuyHVKECUSU29xqDHhZu3tozZDhF4vTAdFvHCqHFv9bbQmuFL8N
```

</div>
</div>

<Warning>
  The in-memory signer holds a raw private key: use it for development and
  tests. In production, use a managed backend so keys stay in dedicated
  infrastructure. See [Choosing a
  backend](/developers/docs/tools/keychain/choosing-a-backend).
</Warning>

## Use a production backend

To sign with a production backend, install its package (or the umbrella
`@solana/keychain`) and construct the signer through the unified factory. For
backends that sign a transaction you own, the signing code stays the same.

```ts title="AWS KMS"
import { createKeychainSigner } from "@solana/keychain";

const signer = await createKeychainSigner({
  backend: "aws-kms",
  keyId: "alias/my-solana-key",
  publicKey: "base58_public_key"
});
```

```ts title="HashiCorp Vault"
import { createKeychainSigner } from "@solana/keychain";

const signer = await createKeychainSigner({
  backend: "vault",
  vaultAddr: "https://vault.example.com:8200",
  vaultToken: "hvs.xxxxx",
  keyName: "my-solana-key",
  publicKey: "base58_public_key"
});
```

See the [TypeScript guide](/developers/docs/tools/keychain/getting-started/typescript) for
every backend's configuration, or
[Choosing a backend](/developers/docs/tools/keychain/choosing-a-backend) to compare custody
models.
