[Contract] openzeppelin/cli 开发, 部署, 升级智能合约
Posted farwish
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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
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 开发, 部署, 升级智能合约的主要内容,如果未能解决你的问题,请参考以下文章
根据word模板(contract_templet.tld)生成并下载word合同及根据wordHTML模板(contract_templetHTML.tld)预览合同内容