Skip to content

Instantly share code, notes, and snippets.

@TheFredStar1
Last active February 21, 2022 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheFredStar1/18db581c2ef825527806a63002c15f4a to your computer and use it in GitHub Desktop.
Save TheFredStar1/18db581c2ef825527806a63002c15f4a to your computer and use it in GitHub Desktop.
Solana - Get keypair from config json
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