6

To be specific I am using ethers version 6.2.3

Error is in this line

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

Entire code I am using to deploy contract and wait

const { ethers, JsonRpcProvider } = require('ethers');
const fs = require('fs-extra');
async function main() {
  const provider = new JsonRpcProvider('http://127.0.0.1:7545');

  const wallet = new ethers.Wallet(
    'private Key', //replace with ganache private key
    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 deploymentReceipt = await contract.deployTransaction.wait(1); // This line has the issue.
  console.log(deploymentReceipt);
}

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

Console

Deploying, Please wait...
TypeError: no matching function (argument="key", value="deployTransaction", code=INVALID_ARGUMENT, version=6.2.3)

code: 'INVALID_ARGUMENT',
  argument: 'key',
  value: 'deployTransaction'
0

5 Answers 5

7

Changing this from ethers v5

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

To this on ethers v6

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

Fixes the issue.

0
0

Try changing to

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

1
  • no same error - no function found. I searched its the issue with ethers version 6. await contract.deploymentTransaction().wait(2); Commented Mar 29, 2023 at 12:30
0
const transactionReceipt = await contract.deploymentTransaction().wait(1);
console.log("Here is the deployment transaction: ");
console.log(contract.deploymentTransaction);
console.log("Here is the transaction receipt: ");
console.log(transactionReceipt);
0

I don't have enough reputation to leave the comment, but if you want to return deployment transaction you need to change this:

console.log(contract.deploymentTransaction);

to this

console.log(contract.deploymentTransaction());
0

This works for me.

const contractFactory = new ethers.ContractFactory(abi,binary,wallet); 
console.log("Deploying please wait....");
const contract = await contractFactory.deploy();
const deploymentReciept = await contract.deploymentTransaction()?.wait(1);

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.