Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

v0.4.0 pre-release!

Pre-release
Pre-release
Compare
Choose a tag to compare
@tcoulter tcoulter released this 24 Feb 18:56
· 16046 commits to master since this release

Hi all! We're gearing up to release v0.4.0 of Truffle. As part of that, we're looking to the community to help test the new version.

Install

First uninstall your current version of Truffle:

$ npm uninstall -g truffle

Next, pull the code from source, since this is a pre-release:

$ git clone https://github.com/ConsenSys/truffle.git
$ cd truffle
$ npm install -g .
$ truffle --version   # => 0.3.9

New Features

There are many:

  • Use truffle.js. You can now include a truffle.js file in your project instead of truffle.json. With truffle.js, you can export your configuration and use Javascript to create that configuration on the fly, as you see fit.

  • Intelligent compilation. Truffle now intelligently compiles only the contracts that have changed instead of recompiling your whole set of contracts during each compile or deploy. This is great for projects with many contracts. Use the --compile-all flag to override this behavior.

  • Automatic library linking. Truffle will analyze your contracts' dependencies and will automatically link libraries to contracts that depend on those libraries during deployment. No need to do this yourself or maintain a separate deploy script!

  • Better log processing during failing tests. If one of your tests fail, Truffle will now better show the logs that applied to that specific failing test rather than display all logs fired over the course of the test run.

  • Mocha configuration in truffle.js. You can now specify the configuration of the test runner (Mocha) within your truffle.js/truffle.json file. To do so, set the key "mocha" to an object that contains the options shown here.

  • Now serve on any port! Nice if you're running multiple development projects at once:

    truffle serve -p 9999
    
  • Specify deployment transaction parameters. You can now specify the gas limit, gas price and from address within your configuration for transactions made during deployment. Just add those values to your rpc configuration, like below:

    module.exports = {
      rpc: {
        host: "localhost",
        port: 8545,
        gas: 3141592 // new! Default gas limit is 3141592
        gasPrice: 100000000000, // new! Default gas price is 100 Shannon.
        from: "..." // new! Default from address is the first address available in your Ethereum client.
      }
    };
    
  • Updated example project. If you run truffle init you'll be given an example project that shows the whole lifecycle of working with a Truffle dapp, including contracts, libraries and tests, as well as a frontend that interacts with those contracts once deployed.

  • Use your own build process. More to come on this feature, but you can now use your own build process instead of the one that comes default with Truffle, while still maintaining your desired level of integration. You can specify this build process in three ways:

    • Change the build keyword to be a string, representing a command to be run when Truffle requires a rebuild of your project:

      module.exports = {
        // This will run the `webpack` command on each build.
        // 
        // The following environment variables will be set when running the command:
        // WORKING_DIRECTORY: root location of the project
        // NODE_ENV: current environment
        // BUILD_DESTINATION_DIRECTORY: expected destination of built assets (important for `truffle serve`)
        // BUILD_CONTRACTS_DIRECTORY: root location of this environment's .sol.js files  
        // WEB3_PROVIDER_LOCATION: rpc configuration as a string, as a URL needed for web3's http provider.
        //
        build: "webpack",
      
        // ...
      }
      
    • Change the build keyword to be a function that will be run on each build:

      module.exports = {
        build: function(options, callback) {
           // Do something when a build is required. `options` contains these values:
           // 
           // working_directory: root location of the project
           // contracts: metadata about your contract files, code, etc.
           // contracts_directory: root directory of .sol files
           // rpc: rpc configuration defined in the configuration
           // environment: current environment
           // destination_directory: directory where truffle expects the built assets (important for `truffle serve`)
        }
        // ...
      }
      
    • Create a module or object that implements the builder interface (i.e., contains a build function as a property that has the same signature as the one above). This is good for tighter integration with other build processes and allows for external modules that can be maintained separately. For instance, see truffle-default-builder:

      var DefaultBuilder = require("truffle-default-builder");
      module.exports = {
        build: new DefaultBuilder(...) // specify the default builder configuration here.
        // ...
      }
      

Breaking changes

  • Solidity upgraded, Truffle imports removed. Before solidity and solc supported its own import mechanism, Truffle provided a feature that could perform imports for you. This included Truffle resolving two keywords within your solidity files, import and import_headers. Truffle has dropped its custom support for these keywords in favor of solc's implementation, which only includes the keyword import. Note that because of this change, you'll need to add the correct file location on the end of all of your imports. i.e., this import:

    import "MyContract";
    

    Must now become:

    import "MyContract.sol";
    

    Note that import_headers is no longer supported at all. To achieve the same behavior, you're better off maintaining an abstract version of the contract in another file and importing the abstract version when required.

Bug Fixes:

  • #40, #56: Tests now ignore non-javascript files.
  • #39, #60, #61, #89: If your contract file no longer defines the contract that Truffle expects, Truffle will throw an error.
  • #75: Solidity upgraded
  • #58: Improper bootstrapping when using the default builder, in some cases.
  • #33: Configurable transaction parameters now available.
  • #70, #71: truffle init and related tests are no longer broken.

Special thanks!

Special thanks to @area, @aaronstjohn, @tom-seddon, @vishakh, @simondlr, @janx, and @dominicwilliams for all their work related to this release. Much appreciated!