Skip to content

PRIVATE_KEY_PASSWORD is not recognized #6702

Closed as not planned
Closed as not planned
@merttanitan1

Description

@merttanitan1

Lesson

Lesson 5

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

https://youtu.be/gyMwXuJrbJQ?t=28062

Operating System

Windows

Describe the bug

When I enter the following command in the terminal, I receive the error: PRIVATE_KEY_PASSWORD=password : The term 'PRIVATE_KEY_PASSWORD=password' is not recognized.

Command:

PRIVATE_KEY_PASSWORD=password node deploy.js

Additional Information:

  • env file:
RPC = "http://127.0.0.1:7545"
  • encryptKey.js File:
require("dotenv").config();
const ethers = require("ethers");
const fs = require("fs-extra");

async function main() {
    const wallet = new ethers.Wallet(process.env.PRIVATE_KEY);
    const encryptedJsonKey = await wallet.encrypt(
        process.env.PRIVATE_KEY_PASSWORD,
        process.env.PRIVATE_KEY
    );
    console.log(encryptedJsonKey);
    fs.writeFileSync("./.encryptedKey.json", encryptedJsonKey);
}
  • deploy.js File Code Block:
const encryptedJson = fs.readFileSync("./.encryptedKey.json", "utf8");
let wallet = new ethers.Wallet.fromEncryptedJsonSync(
    encryptedJson,
    process.env.PRIVATE_KEY_PASSWORD
);

wallet = wallet.connect(provider);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions