smartcontractkit / full-blockchain-solidity-course-js

Learn Blockchain, Solidity, and Full Stack Web3 Development with Javascript
12.4k stars 2.98k forks source link

Lesson5 cannot deployTransaction #5488

Closed xiaopang0626 closed 1 year ago

xiaopang0626 commented 1 year ago

Lesson

Lesson 5

Could you please leave a link to the timestamp in the video where this error occurs? (You can right click a video and "copy video URL at current time")

No response

Operating System

Linux

Describe the bug

I'm getting a TypeError while deploying the error is :

TypeError: no matching function (argument="key", value="deployTransaction", code=INVALID_ARGUMENT, version=6.3.0)
    at makeError (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/utils/errors.js:114:21)
    at assert (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/utils/errors.js:138:15)
    at assertArgument (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/utils/errors.js:150:5)
    at Interface.getFunctionName (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/abi/interface.js:337:39)
    at buildWrappedMethod (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/contract/contract.js:234:34)
    at BaseContract.getFunction (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/contract/contract.js:625:22)
    at Object.get (/home/xp132/hh-fcc/ether-simple-storage/node_modules/ethers/lib.commonjs/contract/contract.js:560:39)
    at main (/home/xp132/hh-fcc/ether-simple-storage/deploy.js:18:45)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'INVALID_ARGUMENT',
  argument: 'key',
  value: 'deployTransaction'
}

My code is here:

const ethers = require("ethers");
const fs = require("fs-extra");
async function main() {
  const provider = new ethers.JsonRpcProvider("http:172.30.0.1:7545");
  const wallet = new ethers.Wallet(
    "0xe57a7fd3b44f2adbbcd1b80c4f084f1fce20d8f0c70f1ba7754cde5edc77a46f",
    provider
  );
  const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
  const binary = fs.readFileSync(
    "./SimpleStorage_sol_SimpleStorage.bin",
    "utf-8"
  );
  const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
  console.log("deploying ~~~");
  const contract = await contractFactory.deploy();
  console.log(contract);
  const transactionReceipt = await contract.deployTransaction.wait(1);
  console.log(transactionReceipt);
}
main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });

and ethers version is v6.3.0 Someone Help~~~

alymurtazamemon commented 1 year ago

@xiaopang0626 In the ethers version 6, it is updated to this;

- const transactionReceipt = await contract.deployTransaction.wait(1);
+ const transactionReceipt = await contract.deploymentTransaction().wait(1);
SWank74 commented 1 year ago

The same change applies to

console.log(contract.deployTransaction);

If you are using ethers version 6 then the above line should be changed to

console.log(contract.deploymentTransaction());