0

ive just started learning solidity and I tried to make a contract and encounter error during running hardhat test .

 1) FortuneTigersPunk
   "before each" hook for "should deploy successfully":
 Error: too many arguments:  in Contract constructor (count=4, expectedCount=0, code=UNEXPECTED_ARGUMENT, version=contracts/5.5.0)
  at Logger.makeError (node_modules\@ethersproject\logger\src.ts\index.ts:225:28)
  at Logger.throwError (node_modules\@ethersproject\logger\src.ts\index.ts:237:20)
  at Logger.checkArgumentCount (node_modules\@ethersproject\logger\src.ts\index.ts:303:18)
  at ContractFactory.<anonymous> (node_modules\@ethersproject\contracts\src.ts\index.ts:1227:16)
  at step (node_modules\@ethersproject\contracts\lib\index.js:48:23)
  at Object.next (node_modules\@ethersproject\contracts\lib\index.js:29:53)
  at C:\Users\loobj\hardhat-tutorial\node_modules\@ethersproject\contracts\lib\index.js:23:71
  at new Promise (<anonymous>)
  at __awaiter (node_modules\@ethersproject\contracts\lib\index.js:19:12)
  at ContractFactory.deploy (node_modules\@ethersproject\contracts\lib\index.js:1132:16)

below is my test script :

describe("FortuneTigersPunk", async () => {
  let FTPContract: Contract;
  let owner: SignerWithAddress;
  let alice: SignerWithAddress;

  beforeEach(async () => {
     const FTPFactory = await ethers.getContractFactory("TigerNft") ;
    [owner, alice] = await ethers.getSigners();

    FTPContract = await FTPFactory.deploy(
      "FortuneTigersPunk",
      "FTP",
      10000,
      1
    );
    console.log(`owner: ${owner.address} alice: ${alice.address}`);

   });
   it("should deploy successfully", async() => {
    console.log("contract address", FTPContract.address);
  });

1 Answer 1

1

The error message is quite clear: too many arguments. This means that your constructor expects 0 arguments (or maybe the contract doesn't have a constructor at all) but you are providing it with 4 arguments.

So either fix your contract or fix your deployment. The constructor is called once, only during deployment, so you have to give it the right amount of arguments.

1
  • tq for your advise~
    – brook18
    Commented Mar 6, 2022 at 16:29

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.