I am getting the error Error: Invalid number of arguments to Solidity function
for the constructor of my contract and no idea why.
I just upgraded to Truffle 4.0.0 beta
and using the truffle develop
test environment instead of testrpc
. These tests used to pass, but now they are giving me errors.
Contract constructor
function MyContract(
bytes _eventName,
bytes32[] _eventResultNames,
uint256 _eventBettingEndBlock,
uint256 _decisionEndBlock,
uint8 _averageBlockTime,
uint256 _arbitrationOptionMinutes)
public
payable
{
...
}
Mocha test class
const params = {
_eventName: "test",
_eventResultNames: ["first", "second", "third"],
_eventBettingEndBlock: 100,
_decisionEndBlock: 120,
_averageBlockTime: 10,
_arbitrationOptionMinutes: 1440
};
const baseReward = Utils.getBigNumberWithDecimals(10, nativeDecimals);
let myContract;
beforeEach(async function() {
myContract = await MyContract.new(...Object.values(params), { from: creator, value: baseReward });
});
Error message
1) Contract: MyContract New MyContract inits the MyContract with the correct values:
Error: Invalid number of arguments to Solidity function
at Object.InvalidNumberOfSolidityArgs (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43993:16)
at SolidityFunction.validateArgs (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:357969:22)
at SolidityFunction.toPayload (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:357985:10)
at SolidityFunction.call (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:358026:24)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326504:16
at Promise (<anonymous>)
at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326495:18
at <anonymous>
How do I fix this error?
Best Answer
Delete your build folder, then run the command. The reset command might work for some, didn't for me, might be a Mac thing.
npm run truffle migrate --reset --compile-all
I find it works best when running truffle locally to the folder rather than globally, due to the beta and different versions getting updated quickly recently. if you prefer the global approach trytruffle migrate --reset --compile-all