smartcontractkit / full-blockchain-solidity-course-js

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

simpleStorage.deployed() #5731

Open Abhishek2061 opened 1 year ago

Abhishek2061 commented 1 year ago

Lesson

Lesson 6

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

None

Describe the bug

async function main() { const SimpleStorageFactory = await ethers.getContractFactory( "SimpleStorage" )
console.log("Deploying Contract...") const simpleStorage = await SimpleStorageFactory.deploy() // await simpleStorage.deployed() // console.log(Deployed contract to:${simpleStorage.address}) }

*So the commented part is having a problem in deployment.

TypeError: no matching function (argument="key", value="address", code=INVALID_ARGUMENT, version=6.6.0) at makeError (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/utils/errors.ts:670:21) at assert (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/utils/errors.ts:694:25) at assertArgument (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/utils/errors.ts:706:5) at Interface.getFunctionName (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/abi/interface.ts:542:23) at buildWrappedMethod (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/contract/contract.ts:334:34) at BaseContract.getFunction (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/contract/contract.ts:849:22) at Object.get (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/node_modules/ethers/src.ts/contract/contract.ts:747:39) at main (/home/niv_2061/fcc-hardhat/hardhat-fcc-first/scripts/deploy.js:11:55) at processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'INVALID_ARGUMENT', argument: 'key', value: 'address' } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.*

kanakjaiswal16 commented 1 year ago

As per the latest Hardhat Documentation:

const SimpleStorageFactory = await ethers.deployContract("SimpleStorage"); console.log("Deploying Contract..."); await SimpleStorageFactory.waitForDeployment(); console.log( Deployed contract to:${await SimpleStorageFactory.getAddress()} );

Or Downgrade your Hardhat version to run the code you have mentioned: npm install --save-dev --save-exact hardhat@2.14.0

theKageEth commented 11 months ago

use await SimpleStorage.waitForDeployment();

theKageEth commented 11 months ago

why its returning [AsyncFunction: getAddress] instead of the contract address?????

theKageEth commented 11 months ago

solved I forgot to add () after getAddress

theKageEth commented 11 months ago

async function main() {
  const SimpleStorageFactory = await ethers.deployContract("SimpleStorage");
  console.log("deploying wait");

  const SimpleStorage = await SimpleStorageFactory.waitForDeployment();

  console.log(await SimpleStorage.getAddress());```
theKageEth commented 10 months ago

console.log(SimpleStorage.target); .target better than getAddress()