PatrickAlphaC / ethers-simple-storage-fcc

90 stars 128 forks source link

TypeError: Cannot read properties of undefined (reading 'wait') #94

Closed kartik01112004 closed 1 year ago

kartik01112004 commented 1 year ago

error with

const deploymentReceipt = await contract.deployTransaction.wait(1);

code:

const ethers = require("ethers"); const fs = require("fs-extra");

async function main() { const provider = new ethers.JsonRpcProvider("http://172.29.240.1:7545"); const wallet = new ethers.Wallet( "0x98cc2e385dbf4dd558e18ca57ae2d1ef041b47b5ae8e1c4195287fcd662a270a", provider ); const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8"); const binary = fs.readFileSync( "./SimpleStorage_sol_SimpleStorage.bin", "utf8" ); const contractFactory = new ethers.ContractFactory(abi, binary, wallet); console.log("Deploying, please wait!.."); const contract = await contractFactory.deploy(); //const contract = await contractFactory.deploy({ gasPrice: 100000000000 }); const deploymentReceipt = await contract.deployTransaction.wait(1); //waiting for 1 block confermation //console.log(deploymentReceipt); console.log(contract); }

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

kartik01112004 commented 1 year ago

After downgrading ethers to 5.7.2 I got another error TypeError: ethers.JsonRpcProvider is not a constructor this was resolved by adding providers to the code const provider = new ethers.providers.JsonRpcProvider( "http://172.29.240.1:7545");

Say-Hello-World commented 1 year ago

After downgrading ethers to 5.7.2 I got another error TypeError: ethers.JsonRpcProvider is not a constructor this was resolved by adding providers to the code const provider = new ethers.providers.JsonRpcProvider( "http://172.29.240.1:7545");

YAH, I ALSO GOT THE SAME PROBLEM !!!