1

Documenting a solution to this error I received while working on a Chainlink contract:

Error Message

Error: missing argument:  in Contract constructor (count=1, expectedCount=2, code=MISSING_ARGUMENT, version=contracts/5.5.0)...

reason: 'too many arguments:  in Contract constructor',
  code: 'UNEXPECTED_ARGUMENT',
  count: 1,
  expectedCount: 0
3

My Solution

This problem occurred with Hardhat. The number of arguments in the contract constructor needed to match the number of arguments in the .deploy() method of the deployment script.

Correct Implementation

// CONTRACT FILE

pragma solidity ^0.8.0;

import "hardhat/console.sol";
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";

contract APIConsumer is ChainlinkClient {
    using Chainlink for Chainlink.Request;
 
   constructor() { // <——— Has 0 arguments
        console.log("Hey!");
    }
}

// DEPLOYMENT SCRIPT

async function main() {
    const APIConsumer = await ethers.getContractFactory("APIConsumer");
    const apiConsumer = await APIConsumer.deploy();  // <——— Must also have 0 arguments

    await apiConsumer.deployed();

    console.log(`APIConsumer deployed to: ${apiConsumer.address}`);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.