知乎專欄 | 多維度架構 | | | 微信號 netkiller-ebook | | | QQ群:128659835 請註明“讀者” |
neo@MacBook-Pro ~/ethereum/truffle % truffle help
Truffle v4.0.6 - a development framework for Ethereum
Usage: truffle <command> [options]
Commands:
init Initialize new and empty Ethereum project
compile Compile contract source files
migrate Run migrations to deploy contracts
deploy (alias for migrate)
build Execute build pipeline (if configuration present)
test Run JavaScript and Solidity tests
debug Interactively debug any transaction on the blockchain (experimental)
opcode Print the compiled opcodes for a given contract
console Run a console with contract abstractions and commands available
develop Open a console with a local development blockchain
create Helper to create new contracts, migrations and tests
install Install a package from the Ethereum Package Registry
publish Publish a package to the Ethereum Package Registry
networks Show addresses for deployed contracts on each network
watch Watch filesystem for changes and rebuild the project automatically
serve Serve the build directory on localhost and watch for changes
exec Execute a JS module within this Truffle environment
unbox Download a Truffle Box, a pre-built Truffle project
version Show version number and exit
See more at http://truffleframework.com/docs
輸出版本號然後退出。
neo@MacBook-Pro ~/ethereum/truffle % truffle version Truffle v4.0.6 (core: 4.0.6) Solidity v0.4.19 (solc-js)
neo@MacBook-Pro ~/ethereum/truffle % truffle console truffle(development)>
neo@MacBook-Pro ~/ethereum/truffle % truffle create contract MyContract neo@MacBook-Pro ~/ethereum/truffle % cat contracts/MyContract.sol pragma solidity ^0.4.4; contract MyContract { function MyContract() { // constructor } }
運行測試
neo@MacBook-Pro ~/ethereum/truffle % truffle test Using network 'development'. Contract: Migrations 1) should assert true > No events were emitted 0 passing (31ms) 1 failing 1) Contract: Migrations should assert true: ReferenceError: Migrations is not defined at Context.<anonymous> (test/migrations.js:3:22)
運行單個測試檔案
neo@MacBook-Pro ~/ethereum/truffle % truffle test test/migrations.js