Lesson 5: TypeError: Cannot read properties of undefined (reading 'toHexString') #6603
Replies: 1 comment
-
const ethers = require("ethers");
const fs = require("fs-extra");
require("dotenv").config(); // Ensure .env variables are loaded
async function main() {
const provider = new ethers.providers.JsonRpcProvider("http://127.0.0.1:7545");
const privateKey = process.env.PRIVATE_KEY;
if (!privateKey) {
throw new Error("PRIVATE_KEY is not defined in .env file");
}
console.log("Private Key:", privateKey);
const wallet = new ethers.Wallet(privateKey, provider);
console.log("Wallet Address:", wallet.address);
}
main().catch((error) => {
console.error(error);
}); Summary of Fixes |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions