$ cd target directory
$ truffle init
Try our scaffold commands to get started:
$ truffle create contract YourContractName # scaffold a contract
$ truffle create test YourTestName # scaffold a test
- modify truffle-config.js (port should be 7545)
- open ganache
- new workspace
- add project
select target truffle-config.js
- save
$ truffle console
$ truffle create contract HelloWorld
- modify contracts/HelloWOrld.sol
$ truffle compile
$ truffle create migration HelloWorld
- modify migrations/16xxxxxxxx_hello_world.js
$ truffle migrate
migrate コマンドは前回のデプロイが成功だった場合、それ以降の新しいマイグレーションだけ実行する。 なので、一度デプロイしたコントラクトコードを修正した場合は以下のコマンドを実行することで新しいコントラクトコードでデプロイしなおす必要がある。
$ truffle migrate --reset
- コンソールから HelloWorld コントラクトの動作確認ができる
$ truffle console
truffle(development)> let helloWorld = await HelloWorld.deployed()
truffle(development)> helloWorld.getMessage()
'Hello World'
$ truffle test