[Contract] openzeppelin/cli 开发, 部署, 升级智能合约
Install Dependency
$ npm init
$ npm install @openzeppelin/cli
Setup project
$ npx openzeppelin init
Write first contract in contracts/, then compile
pragma solidity ^0.5.0; contract Counter { uint256 public value; function increase() public { value++; } }
$ vi contracts/Counter.sol
$ npx oz compile # OR node_modules/@openzeppelin/cli/lib/bin/oz-cli.js compile
Deploy to development network ( Need Ganache, see Truffle flow here. )
$ vi network.js # update Ganache port to 7545
$ npx oz deploy # will auto compile at first
Test contract from terminal, then Query contract' public
$ npx oz send-tx
$ npx oz call
Upgrade your contract
$ vi Counter.sol
$ npx oz upgrade # will auto compile at first
$ npx oz send-tx
$ npx oz call
Refer:Openzeppelin是否智能合约的祸害
Docs: https://docs.openzeppelin.com/cli/2.8/getting-started
How Upgrade works: https://docs.openzeppelin.com/upgrades/2.8/