Created
September 29, 2022 21:03
-
-
Save tracy-codes/f17e7ed8acfdd1be442f632f5b80763c to your computer and use it in GitHub Desktop.
Convert Solana Private Key to base58 Keypair Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install bs58 | |
import bs58 from 'bs58'; | |
import fs from 'fs'; | |
import path from 'path'; | |
// Replace with the private key string that was exported from your solana wallet provider (phantom, etc) | |
const privateKey = "abc123456def"; | |
// bs58.decode will return a ByteArray. | |
const keypairFileData = bs58.decode(privateKey); | |
fs.writeFileSync(path.join(__dirname, 'new-keypair.json'), JSON.stringify(keypairFileData)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment