Sometimes, it's nice to work with your contracts interactively for testing and debugging purposes or to execute transactions by hand. Truffle provides you with an easy way to do this via an interactive console, with your contracts available and ready to use.
To open the console, run this command:
truffle console
The console connects to an ethereum node based on your project configuration. The preceding command also takes a --network option to specify a specific node to connect to.
Here are the features of the console:
- You can run the command in the console. For instance, you can type migrate --reset within the console, and it will be interpreted the same as if you ran truffle migrate --reset from outside the console.
- All of your compiled contracts are available and ready for use.
- After each command (such as migrate --reset), your contracts are re-provisioned, so you can start using the newly assigned addresses and binaries immediately.
- The web3 object is made available and is set to connect to your ethereum node.
- All commands that return a promise will automatically be resolved and the result printed, removing the need to use .then() for simple commands. For example, you can write code like this: MyContract.at("0xabcd...").getValue.call();