Skip to content

Lesson 5 : I can't get the Json of encryptKey.js : Cannot read property 'toHexString' of undefined #552

Answered by wilonweb
wilonweb asked this question in Q&A
Discussion options

You must be logged in to vote

it's okay now, I forgot to put the parentheses to congif

const ethers = require("ethers");
const fs = require("fs-extra");
require("dotenv").config();

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);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bassamejaz
Comment options

@FreezingM
Comment options

Answer selected by wilonweb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants