码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2020-03-28 17:47:01      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:htm   bin   rac   fir   end   arw   http   evel   ++   

 

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

 

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

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

标签:htm   bin   rac   fir   end   arw   http   evel   ++   

原文地址:https://www.cnblogs.com/farwish/p/12588286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!