Created
April 7, 2022 03:24
-
-
Save kevinrodriguez-io/02da537f60b1408688b73d489e596300 to your computer and use it in GitHub Desktop.
Get Solana Anchor Wallet From File System
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 * as anchor from "@project-serum/anchor"; | |
import fs from "fs/promises"; | |
export const getWallet = async (keyPairFile: string) => { | |
const payer = anchor.web3.Keypair.fromSecretKey( | |
Buffer.from( | |
JSON.parse( | |
await fs.readFile(keyPairFile, { | |
encoding: "utf-8", | |
}) | |
) | |
) | |
); | |
return new anchor.Wallet(payer); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment