1

How do you call an overloaded function in Truffle when passing a struct using pragma experimental ABIEncoderV2;?

contract MyContract {

  struct MyStruct {
      address param1;
      address param2;
      address param3;
  }

  function init(address owner) public {}

  function init(MyStruct memory myStruct) public {}
}

Calling MyContract.init(myStruct) tries to call the first init function.

0
3

Related to how to test overloaded function in truffle?, but slightly different with passing a struct. The solution is simple:

MyContract.methods['init((address,address,address))'](myStruct)

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.