DEV Community

Cover image for From Script to Browser: Migrating My First Custom Solana Keypair
Carlos Prada
Carlos Prada

Posted on

From Script to Browser: Migrating My First Custom Solana Keypair

What I Did

I used a simple JavaScript script and the @solana/kit library to programmatically generate a new keypair, saved the secret key to a local .json file, and then wrote a second script to extract that seed so I could manually import it into my Phantom wallet extension for devnet testing.

What Surprised Me

The biggest shift from Web2 was realizing that my "identity" is just a cryptographic string of numbers; once I had that secret key, I could "teleport" my wallet from a raw JSON file on my hard drive directly into a browser extension instantly—no passwords or recovery emails required.

What’s Next

Now that I’ve mastered the "manual" side of key management, I’m looking forward to building a small frontend that allows users to connect their own wallets and sign transactions via the Wallet Adapter.

Note on Security:

  • While this was an incredible learning experience to see how keypairs actually function, remember that storing unencrypted private keys in a .json file is high-risk! This wallet is strictly for devnet experimentation.

100DaysOfSolana @solana_devs

Top comments (1)

Collapse
 
godaddy_llc_4e3a2f1804238 profile image
GoDaddy LLC

Great walkthrough—this is exactly the kind of “aha” moment that makes Web3 click, especially the realization that identity = key material.

One thing worth emphasizing as you go further: what you did here mirrors how many wallets (including Phantom) ultimately derive accounts under the hood, but production setups rarely expose raw keypairs like this. Instead, they rely on mnemonic phrases (BIP39) + deterministic derivation paths, which makes recovery and multi-account management much safer and more scalable.

Also, when you move into building your frontend with Wallet Adapter, you’ll notice a big shift in responsibility:

You never touch the user’s private key
Signing is delegated to the wallet via signTransaction / signMessage
Your app becomes more of a “request layer” than a key manager

If you want to go one level deeper, it might be interesting to:

Compare your generated keypair to one derived from a mnemonic
Explore how Phantom handles account derivation internally
Look into secure key storage patterns (e.g., hardware wallets, encrypted keystores)

Really solid foundation here—this is exactly the right way to understand what’s abstracted away by wallet providers.