Programatically update .openzeppelin/<network-name>.json

The contracts I’m working on have a non-standard deploy scenario and I wrote a script that deploys them. As pointed out by @abcoathup on another forum thread, this doesn’t register the instances created in any project files, so I cannot use oz call and oz send-tx to interact with the deployed contracts.

Is there a way to use OpenZeppelin SDK to perform this update instead of writing custom code that deals with the .openzeppelin/<network-name>.json file?

1 Like

Hi @shark0der,

Thanks for posting in the forum.

Unfortunately there isn’t a way to update the configuration programmatically so that we can interact with contracts. There is an open Issue to add already deployed contracts to the CLI: https://github.com/OpenZeppelin/openzeppelin-sdk/issues/1264

Two potential work arounds:

  • Deploy using a script with cli commands using --no-interactive mode (if you can for your use case)
  • Deploy the contracts using the CLI to setup the configuration and then update the addresses to the ones used by your script.

Do you mind sharing your deploy scenario?

Thanks for the answer @abcoathup!

The deploy scenario is more complicated as it requires deploying 4 contracts then initializing them, enrolling a few users and setting some parameters. Manual deploy using oz send-tx took me half an hour, hence I implemented a JS script to take care of that.

Right now I’ve read the .openzeppelin/<network-name>.json file, added my entries under the proxies section then wrote back to file. While it works at the moment, it is prone to break at some point in the future when oz will be updated.

Perhaps writing a bash script is an option but it’s more convenient to use JS for this.

1 Like