[Contract] Truffle 使用流程
Installation
$ npm install -g truffle
Choose ethereum client (Ganache OR truffle build in `truffle develop`)
https://www.trufflesuite.com/docs/truffle/reference/choosing-an-ethereum-client
Creating a project
$ mkdir truffle-hello
$ cd truffle-hello
$ truffle init # without default contract
OR
$ truffle unbox <box-name> # box-name like MetaCoin
Compiling Contracts
$ truffle compile # all placed in build/contracts/, dot not edit these .json files
Running Migrations
$ truffle migrate [--reset] # run scripts that located in migrations/,Be sure have Ganache installed and running, default choose Ganache network
Deployer https://www.trufflesuite.com/docs/truffle/getting-started/running-migrations#deployer
Testing Contracts
$ truffle test [./tests/hello.js] # NOTE: default network is 'development', so truffle-config.js network configuration need to match the Ganache host and port
Writing tests in javascript
$ truffle test
https://www.trufflesuite.com/docs/truffle/testing/writing-tests-in-javascript
Another tool, openzeppelin/cli 开发, 部署, 升级智能合约
demo: https://github.com/farwish/truffle-hello.git
docs:https://www.trufflesuite.com/docs/truffle/getting-started/installation
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步