Last active
February 21, 2022 20:12
-
-
Save TheFredStar1/18db581c2ef825527806a63002c15f4a to your computer and use it in GitHub Desktop.
Solana - Get keypair from config json
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
import { Keypair } from '@solana/web3.js'; | |
import fs from 'fs/promises'; | |
export const getKeypairFromFile: Promise<Keypair> = async (path) => { | |
const keypairString = await fs.readFile(path, {encoding: 'utf-8'}); | |
const keyPairBuffer = Buffer.from(JSON.parse(keypairString)); | |
return Keypair.fromSecretKey(keyPairBuffer); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment