0

Error is in this line

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

Entire code I am using to deploy contract and wait

const { ethers, run, network } = require("hardhat");

async function main() {
    const simpleStorage = await ethers.deployContract("SimpleStorage");
    console.log("deploying contract... ");
    await simpleStorage.waitForDeployment();
    const simpleStorageAddress = await simpleStorage.getAddress();

    console.log(`Deployed contract contract to : ${simpleStorageAddress}`);
    if (network.config.chainID === 11155111 && process.env.ETHERSCAN_API_KEY) {
        await simpleStorage.deploymentTransaction.wait(3);
        await verify(simpleStorageAddress, []);
    }
}

async function verify(contractAddress, args) {
    console.log("Verifying Contract");
    try {
        await run("verify:verify", {
            address: contractAddress,
            constructorArguments: args,
        });
    } catch (err) {
        if (err.message.toLowerCase().includes("already verified")) {
            console.log("Already Verified");
        } else {
            console.log(err);
        }
    }
}

main()
    .then(() => process.exit())
    .catch((err) => {
        console.log(err);
        process. Exit(1);
    });

Console

$ yarn hardhat run scripts/deploy.js --network sepolia
yarn run v1.22.19
$ "D:\STFU\VS Code\Blockchain\HardHatSimpleStorage\node_modules\.bin\hardhat" run scripts/deploy.js --network sepolia
deploying contract... 
Deployed contract contract to : 0x9D8d3CF1aE495Eb7e4202502f9584cEa0b264690
TypeError: simpleStorage.deploymentTransaction.wait is not a function
    at main (D:\STFU\VS Code\Blockchain\HardHatSimpleStorage\scripts\deploy.js:11:51)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The thing I want to achieve is to wait for few blocks confirmations.

What to do? Please help!

2 Answers 2

0

Replace

 await simpleStorage.deploymentTransaction.wait(3);

with

await simpleStorage.deployTransaction.wait(6)
4
  • it wont work...
    – Aditya
    Jul 6 at 13:13
  • Did you try???? Jul 7 at 4:00
  • yes.. i tried everything i know.. as well as what i could find on internet.. it works for earlier versions ethers but not for 6.4.0
    – Aditya
    Jul 12 at 12:35
  • the correct syntax is: await simpleStorage.deploymentTransaction().wait(3); note the round parenthesis
    – mariuss
    Nov 30 at 21:03
0
await simpleStorage.deploymentTransaction().wait(3);

Note that deploymentTransaction is a function call, it requires the round parenthesis.

Your Answer

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

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