Environment
Any OpenZeppelin SDK version
Details
I’ve read through the documentation, but I’m still not totally clear on what a full start-to-finish workflow would look like with the OpenZeppelin CLI.
There’s a few commands where I’m not sure how they’d fit in. These are:
npx oz freeze
npx oz publish
npx oz push
npx oz session
Here is my current best shot at putting together this full workflow, which doesn’t use the commands above. Please me know which parts of the below workflow are incorrect or can be improved upon!
Setup, Development, and Testing
-
Initialize our project with
npx oz init projectName
-
Link the OpenZeppelin contracts we’ll be using as dependencies with
npx oz link @openzeppelin/contracts-ethereum-package
— What exactly is happening here that’s different than manually installing an npm package?
Now we develop our contracts, test them, and just play around with the CLI to get a feel for things
Deployment
-
When ready for “real” deployment to the mainnet or a testnet, we first reset the project using the steps in this forum post, summarized below:
-
Delete the
build
directory -
Delete all
<network>.json
files -
Remove all contracts from
project.json
usingnpx oz remove contractName1 contractName2
-
-
Compile all contracts with desired Solidity version, e.g.
npx oz compile --solc-version 0.5.12
-
Add all contracts you will be deploying to your project to the
project.json
file by runningnpx oz add contractName1 contractName2
-
Deploy each contract with
npx oz create
. During these step we also call theinitialize()
function on each contract. -
Verify them on Etherscan/Etherchain with
npx oz verify
-
Now our initial deployments are done. To reduce the risk of malicious upgrades we want to change the upgradeability admin for all contracts to be a hardware wallet. We do this with
npx oz set-admin
At this point we are done with deployment and are contract/dapp can be used by others on whichever network we deployed to.
Upgrade Contracts
-
Our contracts have been running for some time, and we now want to upgrade one or more of them
-
Upgrade the version number using
npx oz bump <new-version>
, and manually upgrade the version number inpackage.json
. -
Now we change the admin back from the hardware wallet using
npx oz set-admin
— But how do we send this transaction from the hardware wallet. Is a certain npm package needed to interface with it? -
Use
npx oz upgrade
to upgrade a single contract, ornpx oz upgrade --all
to upgrade all contracts. -
Repeat steps 5-6 of the previous section (verify, change upgradeability admin)
-
If we ever decide we no longer want a contract to be upgradeable, use
npx oz set-admin
to change the upgradeability admin to the zero address.