Files
2025-12-27 21:16:53 -08:00

32 lines
888 B
TypeScript

import * as dotenv from "dotenv";
dotenv.config();
import { Wallet } from "ethers";
import password from "@inquirer/password";
async function main() {
const encryptedKey = process.env.DEPLOYER_PRIVATE_KEY_ENCRYPTED;
if (!encryptedKey) {
console.log("šŸš«ļø You don't have a deployer account. Run `yarn generate` or `yarn account:import` first");
return;
}
console.log("šŸ‘€ This will reveal your private key on the console.\n");
const pass = await password({ message: "Enter your password to decrypt the private key:" });
let wallet: Wallet;
try {
wallet = (await Wallet.fromEncryptedJson(encryptedKey, pass)) as Wallet;
} catch {
console.log("āŒ Failed to decrypt private key. Wrong password?");
return;
}
console.log("\nšŸ”‘ Private key:", wallet.privateKey);
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});