Getting Started

React

Reference

Using Truffle Develop and the Console

Sometimes it's nice to work with your contracts interactively for testing and debugging purposes, or for executing transactions by hand. Truffle provides you two easy ways to do this via an interactive console, with your contracts available and ready to use.

You are testing your project with no intention of immediately deploying

You don't need to work with specific accounts (and you're fine with using default development accounts)

You don't want to install and manage a separate blockchain client

Commands

All commands require that you be in your project folder. You do not need to be at the root.

Console

To launch the console:

truffle console

This will look for a network definition called development in the configuration, and connect to it, if available. You can override this using the --network <name> option. See more details in the Networks section as well as the command reference.

When you load the console, you'll immediately see the following prompt:

truffle(development)>

This tells you you're running within a Truffle console using the development network.

Truffle Develop

To launch Truffle Develop:

truffle develop

This will spawn a development blockchain locally on port 9545, regardless of what your truffle-config.js configuration file calls for. If you already have a truffe develop session running, it will instead connect to that development blockchain.

This shows you the addresses, private keys, and mnemonic for this particular blockchain.

Note: When you run truffle develop for the first time, Truffle will generate a random mnemonic that will persist for you and you alone. If you want to use a different mnemonic or set of addresses, we recommend using Ganache.

Warning: Remember to never use any of these addresses or the mnemonic on the mainnet. This is for development only.

Configuring Truffle Develop

You can configure truffle develop to use any of the available
ganache-core options.

Features

Both Truffle Develop and the console provide most of the features available in the Truffle command line tool. For instance, you can type migrate --reset within the console, and it will be interpreted the same as if you ran truffle migrate --reset on the command line.

Additionally, both Truffle Develop and the console have the following features:

All of your compiled contracts are available and ready for use.

After each command (such as migrate --reset) your contracts are reprovisioned so you can start using the newly assigned addresses and binaries immediately.

The web3 library is made available and is set to connect to your Ethereum client.

Commands available

build

compile

create

debug

deploy

exec

help

install

migrate

networks

opcode

publish

run

test

version

If a Truffle command is not available, it is because it is not relevant for an existing project (for example, init) or wouldn't make sense (for example, develop or console).