[Contract] openzeppelin/cli 开发, 部署, 升级智能合约

通过llama.cpp与羊驼聊天的网页界面- 详解 Serge 的启动使用

 

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/

Link:https://www.cnblogs.com/farwish/p/12588286.html

posted on 2020-03-28 17:20  ercom  阅读(692)  评论(0编辑  收藏  举报