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

async function main() {
  // http://127.0.0.1:7545
  let provider = new ethers.JsonRpcProvider("http://127.0.0.1:7545");
  const wallet = new ethers.Wallet(
    "0xb837e61da0f71b2b895e3b165dac7e883e25cf34b6284f6e1118a45e99013e14",
    provider
  );
  const abi = fs.readFileSync(
    "./ethers-simple-storage_SimpleStorage_sol_SimpleStorage.abi",
    "utf8"
  );
  const binary = fs.readFileSync(
    "./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(); //STOP here! Wait for contrat to be deployed.

  const transactionReceipt = await contract.deploymentTransaction.wait(1);
  console.log(transactionReceipt);

  console.log("Done!");
}

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

My instructor used this code

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

but when I try to write deploy.Transaction it automatically writes deploymentTransaction. Please help me with this Im stuck for hours now!!!!!

1 Answer 1

2

remove this line:

const transactionReceipt = await contract.deploymentTransaction.wait(1);

And replace it by this:

const transactionReceipt = await contract.deploymentTransaction().wait(1);

deploymentTransaction is a function, see documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.