This file contains hidden or 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
// This nodejs script read solana keypair file([1,22,19,45,75,..., ]) and out public key and private key to command line | |
const fs = require('fs') | |
const { Keypair } = require('@solana/web3.js') | |
const bs58 = require('bs58') | |
const keypairData = JSON.parse(fs.readFileSync('./<YOUR_KEYPAIR_FILE>.json')) | |
const keypair = Keypair.fromSecretKey(Uint8Array.from(keypairData)) | |
console.log('Private key (base58):', bs58.encode(keypair.secretKey)) | |
console.log('Public key (base58):', keypair.publicKey.toBase58()) |