Lesson 5 : TypeError: Cannot read properties of undefined (reading 'toHexString') #6562
-
hi, guys! I'm having this problems: TypeError: Cannot read properties of undefined (reading 'toHexString')
at isHexable (/home/ssj/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/bytes/lib/index.js:9:21)
at arrayify (/home/ssj/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/bytes/lib/index.js:69:9)
at getPassword (/home/ssj/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/wallet/node_modules/@ethersproject/json-wallets/lib/utils.js:25:33)
at encrypt (/home/ssj/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/wallet/node_modules/@ethersproject/json-wallets/lib/keystore.js:257:49)
at Wallet.encrypt (/home/ssj/hh-fcc/ethers-simple-storage/node_modules/@ethersproject/wallet/lib/index.js:210:51)
at main (/home/ssj/hh-fcc/ethers-simple-storage/encryptKey.js:7:41)
at Object.<anonymous> (/home/ssj/hh-fcc/ethers-simple-storage/encryptKey.js:14:1)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32) This is my encryptKey.js 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);
}); This is my .env file
And, this is my package.json {
"dependencies": {
"dotenv": "^16.4.5",
"ethers": "^5.6.2",
"fs-extra": "^11.2.0",
"solc": "0.8.8"
},
"scripts": {
"compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol "
}
}
Who can help me? |
Beta Was this translation helpful? Give feedback.
Answered by
shisanjin123
Apr 17, 2024
Replies: 1 comment
-
my .env file: |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
shisanjin123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my .env file:
PRIVATE_KEY_PASSWPRD=password
should to write to thisPRIVATE_KEY_PASSWORD=password