These documents are out of date

Please visit the page on the new documentation site for up to date information.

Usage

$ truffle [command] [options]

Available Commands

build

Build a development version of the app; creates the ./build directory.

$ truffle build

Optional parameters:

  • --dist: Build a distributable version of the app. Only applicable when using the default builder.

See the Building your application section for more details.

console

Run a console with your contract objects instantiated and ready to use.

$ truffle console

Once the console starts, you can then use your contracts via the command line like you would in your code. Additionally, all truffle commands listed here are available within the console.

Optional parameters:

  • --network name: Specify the network to use.
  • --verbose-rpc: Log communication between Truffle and the RPC.

See the Using the console section for more details.

compile

Intelligently compile your contracts. This will only compile contracts that have changed since the last compile, unless otherwise specified.

$ truffle compile

Optional parameter:

  • --compile-all: Compile all contracts instead of intelligently choosing.
  • --network name: Specify the network to use, saving artifacts specific to that network.
create:contract

Helper method to scaffold a new contract. Name must be camel-case.

$ truffle create:contract MyContract
create:test

Helper method to scaffold a new test for a contract. Name must be camel-case.

$ truffle create:test MyTest
migrate

Run your project's migrations. See the Migrations section for more details.

$ truffle migrate

Optional parameters:

  • --reset: Run all migrations from the beginning, instead of running from the last completed migration.
  • --network name: Specify the network to use, saving artifacts specific to that network.
  • --to number: Migrate from the current migration to the migration specified in to.
  • --compile-all: Compile all contracts instead of intelligently choosing.
  • --verbose-rpc: Log communication between Truffle and the RPC.
exec

Execute a Javascript file within the Truffle environment. This will include web3, set the default provider based on the network specified (if any), and include your contracts as global objects while executing the script. Your script must export a function that Truffle can run. See the Writing external scripts section for more details.

$ truffle exec /path/to/my/script.js

Optional parameter:

  • --network name: Specify the network to use, using artifacts specific to that network.
init

Create a completely new app within the current working directory. Will add default contracts, tests and frontend configuration.

$ truffle init
list

List all available commands and exit. Synonymous with --help.

$ truffle list
serve

Serve the built app from http://localhost:8080, rebuilding and redeploying changes as needed. Like truffle watch, but with the web server component added.

$ truffle serve

Optional parameters:

  • -p port: Specify the port to serve on. Default is 8080.
  • --network name: Specify the network to use, using artifacts specific to that network.
test

Run all tests within the ./test directory, or optionally run a single test.

$ truffle test [/path/to/test/file]

Optional parameters:

  • --compile-all: Compile all contracts instead of intelligently choosing.
  • --verbose-rpc: Log communication between Truffle and the RPC.
  • --network name: Specify the network to use, using artifacts specific to that network.
version

Show version number and exit.

$ truffle version
watch

Watch for changes to contracts, app and configuration files. When there's a change, rebuild the app if necessary.

$ truffle watch