> ## 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 Create a Keypair

> Every transaction requires a signature from a keypair on Solana. Learn how to create Keypairs on Solana.

To send a transaction on the Solana blockchain, you need a valid signature from
a keypair or wallet. If you are
[connecting to a wallet application](/developers/cookbook/wallets/connect-wallet-react)
(eg. Phantom or Solflare), the wallet manages the keypair for you, so you don’t
need to create one yourself. However, if you are not using a wallet, you will
need to generate a keypair to sign your transactions.

<Warning>
  A keypair created this way holds a raw private key. Never embed one in
  client-side code or commit it to source control. For backend services in
  production, use a key-management backend instead — see [Signing in
  Production](/developers/docs/core/transactions/signing-in-production).
</Warning>

## Generate a keypair

<Tabs>
<Tab title="Kit">
<div className="sol-tab-label">Kit</div>

```ts
import { generateKeyPairSigner } from "@solana/kit";

const signer = await generateKeyPairSigner();
console.log("address: ", signer.address);
```

<div className="sol-run" data-run="cookbook/wallets/create-keypair/create" data-tab="Kit" data-runner="generate-keypair">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Example output: each run generates a new key pair</span></div>
<div className="sol-run-out">

```text Output
address:  DxQ6RYwhfmX66AQCf3B8aL4P9EivuXnf8HQBkFZwZZFJ
```

</div>
<pre className="sol-run-live" aria-live="polite"></pre>
</div>

</Tab>
<Tab title="Web3.js v3">
<div className="sol-tab-label">Web3.js v3</div>

```ts
import { Keypair } from "@solana/web3.js";

const keypair = await Keypair.generate();
console.log("address:", keypair.publicKey.toBase58());
```

<div className="sol-run" data-run="cookbook/wallets/create-keypair/create" data-tab="Web3.js v3" data-runner="generate-keypair">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Example output: each run generates a new key pair</span></div>
<div className="sol-run-out">

```text Output
address: Ddws1nufDuX8c6Zjbb3piTmbHwv9mxsDknftuSVSsGdJ
```

</div>
<pre className="sol-run-live" aria-live="polite"></pre>
</div>

</Tab>
<Tab title="Rust">
<div className="sol-tab-label">Rust</div>

```rust
use solana_sdk::{signature::Keypair, signer::Signer};

fn main() {
    let keypair = Keypair::new();
    let address = keypair.pubkey();

    println!("address: {address}")
}
```

<div className="sol-run" data-run="cookbook/wallets/create-keypair/create" data-tab="Rust" data-runner="generate-keypair">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Example output: each run generates a new key pair</span></div>
<div className="sol-run-out">

```text Output
address: CLKDUYSkw17fnDwz4D56f2k2YjCwKBtTFPfcHfuGuER3
```

</div>
<pre className="sol-run-live" aria-live="polite"></pre>
</div>

</Tab>
<Tab title="Python">
<div className="sol-tab-label">Python</div>

```py
from solders.keypair import Keypair

keypair = Keypair()
address = keypair.pubkey()

print(f"address: {address}")
```

<div className="sol-run" data-run="cookbook/wallets/create-keypair/create" data-tab="Python" data-runner="generate-keypair">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Example output: each run generates a new key pair</span></div>
<div className="sol-run-out">

```text Output
address: HAHS8kNi3fKipxwN7VEQdwzLgTNZtqGynTF8SD995ZRx
```

</div>
<pre className="sol-run-live" aria-live="polite"></pre>
</div>

</Tab>
<Tab title="Go">
<div className="sol-tab-label">Go</div>

```go
package main

import (
	"fmt"

	"github.com/solana-foundation/solana-go/v2"
)

func main() {
	keypair := solana.NewWallet()
	address := keypair.PublicKey()

	fmt.Printf("address: %s\n", address)
}
```

<div className="sol-run" data-run="cookbook/wallets/create-keypair/create" data-tab="Go" data-runner="generate-keypair">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Example output: each run generates a new key pair</span></div>
<div className="sol-run-out">

```text Output
address: CG5x7f2t6cnBYU641YAZQfdaxD11JacW64NEKSdMbAt2
```

</div>
<pre className="sol-run-live" aria-live="polite"></pre>
</div>

</Tab>
<Tab title="Web3.js (legacy)">
<div className="sol-tab-label">Web3.js (legacy)</div>

<Warning>
  **`@solana/web3.js` 1.x is no longer actively maintained**

  It receives critical fixes only. Use [Kit](/developers/docs/clients/official/javascript#solana-kit) for new code. To migrate existing code, follow the [Kit upgrade guide](https://www.solanakit.com/docs/upgrade-guide), or the [web3.js v3 migration guide](https://github.com/solana-foundation/solana-web3.js/blob/main/docs/web3js-v1-to-v3-migration.md) to keep the class-based API.

  To run this code, install 1.x with `npm install @solana/web3.js@1`. A plain `npm install @solana/web3.js` installs v3, which this code doesn't run on.
</Warning>

```ts
import { Keypair } from "@solana/web3.js";

const keypair = Keypair.generate();
console.log("address:", keypair.publicKey.toBase58());
```

<div className="sol-run" data-run="cookbook/wallets/create-keypair/create" data-tab="Web3.js (legacy)" data-runner="generate-keypair">
<div className="sol-run-bar"><button type="button" className="sol-run-btn">Run</button><span className="sol-run-note">Example output: each run generates a new key pair</span></div>
<div className="sol-run-out">

```text Output
address: 27FGjnR9yaNe6s53Z9YHigUMhQqhzUU14GXbgzwBHMqg
```

</div>
<pre className="sol-run-live" aria-live="polite"></pre>
</div>

</Tab>
</Tabs>
