0

Im starting to learn Solidity, and i have some issues when i try when i try npx hardhat run

The error itself:

TypeError: no matching function (argument="key", value="format", code=INVALID_ARGUMENT, version=6.6.2)
    at makeError (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\utils\errors.ts:670:21)
    at assert (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\utils\errors.ts:694:25)
    at assertArgument (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\utils\errors.ts:706:5)
    at Interface.getFunctionName (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\abi\interface.ts:542:23)      
    at buildWrappedMethod (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\contract\contract.ts:334:34)
    at BaseContract.getFunction (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\contract\contract.ts:849:22)   
    at Object.get (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\contract\contract.ts:747:39)
    at Function.from (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\abi\interface.ts:1259:33)
    at new ContractFactory (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\ethers\src.ts\contract\factory.ts:53:33)
    at getContractFactoryByAbiAndBytecode (C:\Users\santi\OneDrive\Documents\PROYECTOS\Development\Solidity\my-wave-portal\node_modules\@nomicfoundation\hardhat-ethers\src\internal\helpers.ts:309:10) {
  code: 'INVALID_ARGUMENT',
  argument: 'key',
  value: 'format'
}

The script:

const main = async () => {
  const waveContractFactory = await hre.ethers.getContractFactory("WavePortal");
  console.log(waveContractFactory)
  const waveContract = await waveContractFactory.deploy();
/*   console.log(waveContract); */
  await hre.ethers.deployContract(waveContract);
  /*     await .deployed() */
  await waveContract.waitForDeployment();
  const address = await waveContract.getAddress();
  console.log("this is the ADDRESS",address)
  console.log("Contract deployed to: ", address);
};

const runMain = async () => {
  try {
    await main();
    process.exit(0);
  } catch (error) {
    console.log(error);
    process.exit(1);
  }
};

runMain();

And the contract itself:

pragma solidity ^0.8.9;

import "hardhat/console.sol";

contract WavePortal{
    constructor(){
        console.log("Hola!");
    }
}

i understand that solidity 6 has a lot of differences from older versions, but i dont find my mistake

1 Answer 1

0

Use either contractFactory.deploy() or ethers.deployContract(), not both.

As you are already using the contractFactory, you can just remove the await hre.ethers.deployContract(waveContract) line and it should work.

1
  • 1
    Thanks @ceseshi ! It works for me!! Commented Jul 5, 2023 at 15:15

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.