Error during zos create - 'Could not find initialize method'

Apologies if this has been covered elsewhere. I’m currently looking to create an instance of a contract in our library, and after successfully adding the contract and deployment, when I try to create the instance I get this error Could not find method initialize with 1 arguments in contract. The ProxyAdmin does get deployed however. This is the initializer function in the referenced contract:

    function initialize(
        address _resolverAddress,
        address _xyERC20,
        address _plcr,
        uint[] memory _parameters
    ) initializer public {
        resolverAddress = _resolverAddress;
        super.init(_xyERC20, _plcr, _parameters);
    }

This is a converted constructor function, and I also tried to add the initializer to the ancestor, but got a TypeError linearization of inheritance graph impossible

I did manage to create an instance in another contract in our library successfully. It is a initialize without arguments, but I can’t see any other reason why this initializer can’t be seen.

Hello @pllearns! I’m not sure what’s going on here so I’m gonna tag @spalladino to help you out :smiley:

1 Like

Hi @pllearns, I think this error can occur when you add space after the first argument when you call create (instead of use commas without spaces)

zos create MyContract --init initialize --args 33 xxx

it causes error Could not find method initialize with 1 argument in contract MyContract

and the correct way is:
zos create MyContract --init initialize --args 33,xxx
Hope to help

2 Likes

Trying that right now. Thanks! @paulinablaszk

I did try that, but I got a bad pattern after trying commas without spaces, and commas with spaces

@paulinablaszk @IvanTheGreatDev @spalladino figured it out. No matter what the value of the arguments, I had to wrap them in quotation marks. Thanks for the help! Truly appreciated!

3 Likes

If I recall correctly, we modeled our argument parser after Remix's, which is admittedly sort of wonky. Could you share the final version of the command that ended up working for you, both for future reference and so that we can improve our documentation to cover that case? Thanks!

2 Likes

Yep! Sorry I didn’t see this earlier, here is the command with some dummy data matching the arguments from the initializer I wrote in the post:
zos create <contractName> --init initialize --args "0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1,0x9561c133dd8580860b6b7e504bc5aa500f0f06a7,0x9561c133dd8580860b6b7e504bc5aa500f0f06a7,[ 100000000000000000000, 1200, 1200, 1200, 1200, 50, 50, 66, 0, 0, 200, 300 ]"

2 Likes