TypeError: Cannot read properties of undefined (reading 'ReadFileSync') #6691
Unanswered
abhinavreddyyy
asked this question in
Q&A
Replies: 1 comment 2 replies
-
right now Im going to tag @PatrickAlphaC |
Beta Was this translation helpful? Give feedback.
2 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.
-
const { ethers } = require("ethers");
const { fs } = require("fs-extra");
require("dotenv").config();
async function main() {
const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL);
const encryptedJson = fs.readFileSync("./.encryptedKey.json", "utf8");
let wallet = new ethers.Wallet.fromEncryptedJsonSync(
encryptedJson,
process.env.PRIVATE_KEY_PASSWORD
);
wallet = await wallet.connect(provider);
const abi = readFileSync(
"./hh-fcc/ethers-simple-storage_SimpleStorage_sol_SimpleStorage.abi",
"utf8"
);
const binary = readFileSync(
"./hh-fcc/ethers-simple-storage_SimpleStorage_sol_SimpleStorage.bin",
"utf8"
);
const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
console.log("Deploying, please wait...");
const contract = await contractFactory.deploy();
await contract.deployTransaction.wait(1);
const currentFavoriteNumber = await contract.retrieve();
console.log(
Current Favorite Number: ${currentFavoriteNumber.toString()}
);const transactionResponse = await contract.store("7");
const transactionReceipt = await transactionResponse.wait(1);
const updatedFavoriteNumber = await contract.retrieve();
console.log(
Updated favorite number is: ${updatedFavoriteNumber}
);}
main() // code for waiting the above code to finish
.then(() => process.exit(0)) //and then print any errors
.catch((error) => {
console.error(error);
process.exit(1);
});
For this code I'm getting an error: TypeError: Cannot read properties of undefined (reading 'readFileSync')
Beta Was this translation helpful? Give feedback.
All reactions