-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypt.js
More file actions
20 lines (18 loc) · 825 Bytes
/
encrypt.js
File metadata and controls
20 lines (18 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const fs = require("fs");
const { ethers } = require("ethers");
require("dotenv").config();
const encrypt = async () => {
console.log("\x1b[33mEncrypting Wallet, Please Wait...\x1b[0m");
const wallet = new ethers.Wallet(process.env.METAMASK_PRIVATE_KEY);
const encryptedWallet = await wallet.encrypt(process.env.WALLET_PASSWORD);
console.log("\x1b[32mWallet Encrypted Successfully!");
console.log("\x1b[33mSaving Encrypted Wallet into File System, Please wait...\x1b[0m");
fs.writeFileSync("./.encryptedJson.json", encryptedWallet, "utf8");
console.log("\x1b[32mEncrypted Json Key Saved into FileSystem Successfully!\x1b[0m");
};
encrypt()
.then(() => process.exit(0))
.catch((err) => {
console.log(`\x1b[31mdeploy.js -- ERROR: ${err} \x1b[0m`);
process.exit(1);
});