2

I recently upgraded truffle to the newest version. Now it does not automatically detect overloaded functions anymore. Before, I could just do the following:

await contract.function({
  from: accounts[0],
  value: web3.utils.toWei("0.5", "Ether")
});

await contract.function(param1, param2, {
  from: accounts[0],
  value: web3.utils.toWei("0.5", "Ether")
});

Now it seems that I have to specify the parameters in a syntax like the following:

await contract.function['uint256', 'uint256'](param1, param2, {
  from: accounts[0],
  value: web3.utils.toWei("0.5", "Ether")
});

But how can I declare the first function version without parameters? Doing this: contract.function[''](...) produces the error contract.function is not a function. Not declaring anything via [] produces the same error as well.

Also the parameters for the overloaded functions are two arrays. One address[] array and one uint256[] array. I already tried:

contract.function["address[]", "uint256[]"](addressList, uintList, {...})

which doesn't work. It produces the same error.

I also didn't find any information about this in the truffle documentation.

  • Please post your contract. – goodvibration Feb 26 at 14:41
  • What do you get from $ truffle version ? – Rob Hitchens - B9lab Feb 26 at 15:06
  • Truffle version returns Truffle v5.0.0-next.26 (core: 5.0.0-beta.2) Solidity - 0.5.4 (solc-js) Node v8.11.4 – Jambo Dev Feb 26 at 15:08
1

Make sure you upgrade to the latest version of Truffle, and then check out these release notes on overloaded functions: https://github.com/trufflesuite/truffle/releases/tag/v5.0.0#user-content-what-s-new-in-truffle-v5-interacting-with-your-contracts-overloaded-solidity-functions

I hope that helps a little!

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.