The Truffle command-line interface (CLI) provides a powerful set of tools for managing your Ethereum development environment. Below is a list of some commonly used Truffle CLI commands, categorized for easy reference.

Project Management

  • truffle init: Initializes a new Truffle project.
  • truffle migrate: Deploys contracts to the blockchain.
  • truffle migrate --reset: Deploys contracts and resets the blockchain state.
  • truffle console: Opens an interactive JavaScript console for debugging.
  • truffle exec <file>: Executes a JavaScript file with the Truffle environment.

Contract Development

  • truffle compile: Compiles contracts in the contracts directory.
  • truffle test: Runs tests located in the test directory.
  • truffle develop: Starts a development server for testing.

Deployment

  • truffle deploy: Deploys contracts to a specified network.
  • truffle networks: Lists all networks configured for the project.

Network Management

  • truffle network set <name> <config>: Sets the configuration for a network.
  • truffle network add <name> <config>: Adds a new network configuration.

Environment Variables

  • truffle config: Lists all environment variables used by Truffle.
  • truffle unbox: Unboxes a Truffle Box, which is a ready-to-use Truffle project.

For more detailed information and additional commands, please visit the Truffle documentation.

Example

Here is a simple example of how to deploy a contract using the truffle migrate command:

truffle migrate --network development

This command will deploy the contracts in the contracts directory to the development network.

For more information on networks, please refer to the Truffle network documentation.

[center] Truffle CLI Commands [center]