npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

solana-keygen

v0.1.3

Published

This repository contains a lightweight, **Bun-based** TypeScript tool for generating and exporting Solana key pairs.

Readme

Solana Keygen

This repository contains a lightweight, Bun-based TypeScript tool for generating and exporting Solana key pairs.

It can be used via bunx for quick command-line key generation or as a library in your own projects.

It is designed to be a drop-in for projects that need programmatic key creation without relying on the official Solana CLI or heavy dependencies.

Command-Line Usage

This tool is meant to be run using bunx.

Generate a new keypair

bun x solana-keygen@latest

Output:

{
  "address": "...",
  "base58": "...",
  "byteArray": "..."
}

Extract the base58 secret key

This is useful for importing into Phantom, Solflare, or other wallets.

bun x solana-keygen@latest | jq -r .base58

Export to environment variables

You can use jq to easily export the keys for use in scripts.

export SOLANA_FEE_PAYER=$(bun x solana-keygen@latest | jq -r .base58)

Or, to get both the address and the secret key:

eval $(bun x solana-keygen@latest | jq -r '"SOLANA_ADDRESS=\(.address)\nSOLANA_SECRET_KEY=\(.base58)"')

You can use this to add or append values to an .env file:

bun x solana-keygen@latest | jq -r '"SOLANA_FEE_PAYER_ADDRESS=\(.address)\nSOLANA_FEE_PAYER_SECRET=\(.base58)"' >> .env

Library Usage

You can also use this package as a library to integrate key generation into your own projects.

Features

  • Extractable Ed25519 key pairs – generated from random bytes.
  • Export to multiple formats:
    • Secret key (64 bytes, private + public)
    • Separate 32-byte private & public keys
    • Base58 string (compatible with Solana tooling)
    • JSON array of bytes
  • Built entirely with Bun and the native Web Crypto API and @solana/kit.
  • Fully typed with TypeScript and includes a small test suite that runs via bun test.

Installation

bun add solana-keygen

Example

import { solanaKeygen } from 'solana-keygen'

async function demo() {
  const result = await solanaKeygen()

  console.log('Address:', result.address)
  console.log('Secret key (Base58):', result.base58)
  console.log('Secret key (JSON array):', result.byteArray)
}

demo()

You can also use the lower-level functions for more control:

import { generateKeyPairSignerExtractable } from 'solana-keygen'
import { exportKeyPairToSecretKey } from 'solana-keygen'
import { exportKeyPairToBytes } from 'solana-keygen'
import { exportKeyPair } from 'solana-keygen'

async function demo() {
  const signer = await generateKeyPairSignerExtractable()

  // Secret key (64 bytes)
  const secretKey = await exportKeyPairToSecretKey(signer.keyPair)

  // Separate private/public
  const { privateKey, publicKey } = await exportKeyPairToBytes(signer.keyPair)

  // Base58 & JSON
  const { base58, byteArray } = await exportKeyPair(signer.keyPair)
  console.log({ base58, byteArray })
}

demo()

Testing

Run the bundled tests with:

bun test

The test suite validates:

  • Extractability of keys.
  • Correctness of exported formats.
  • Uniqueness of generated key pairs.

Project Structure

src/
├─ cli.ts # Command-line interface entry point
├─ solana-keygen.ts # Main keygen function
├─ export-key-pair-to-bytes.ts # Export private/public as Uint8Array
├─ export-key-pair-to-secret-key.ts # Export 64-byte secret key
├─ export-key-pair.ts # Export base58 string & JSON array
├─ generate-key-pair-signer-extractable.ts # Key generation helper
└─ index.ts # Re-exports public API

test/
├─ ... test files matching src modules

License

MIT – see LICENSE.