3

I get type errors in hardhat when my contracts have two versions of the same function which differ only by call signature, i.e.

contract MyContract {

 string memory public _defaultVersion ="1.0.0"

 function addParameter(string memory paramName) public {
    addParameter(paramName, _defaultVersion);
 }

 function addParameter(string memory paramName, string memory version) public {
    [code to add a parameter]
 }
}

I don't get a compile error, but when I run hardhat test which includes a call to addParameter I get TypeError: myContract.addBindingParameter is not a function, no matter which call signature I use. If I delete one of the functions from my contract the test runs normally. (This doesn't appear to be a problem with function calls inside the solidity contract which appear to properly discriminate between the function calls based on the supplied parameters).

Is it possible to use these variant function (same function name, different params) with hardhat/ethers? If so what's the proper way to call?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.