Getting started with Buidler

Increase your productivity with flexible Ethereum development tools

Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want. Take a look at our vision post or head over to Github to learn more.

In this guide, we’ll explore how to start using Buidler in your Ethereum project.

What makes Buidler special? What can you achieve with it?

Buidler allows you to streamline your development workflow by making it easy to incorporate other tools into your process, as well as granting you all the flexibility you need to adapt the tools to your exact needs. What dependencies and tools you use is up to you. Buidler will only help you orchestrate them.

Out of the box, you can compile your Solidity code, install plugins and create your own tasks.

Let’s install it to try it out:

npm install @nomiclabs/buidler

To create a Buidler project just run npx buidler in your project folder:

Let’s create the sample project and go through the steps to try out the sample task, compile, test and deploy the sample contract.

If you take a look at buidler.config.js, you will find the definition of the task accounts:

NOTE: in the Buidler 1.0.0 beta release we’ve disabled the automatic ganache instance feature to keep working on its stability, so you’ll need to run it manually. This feature will be back by the time we ship the stable release. Run ganache-cli.

To run it, try npx buidler accounts:

If you would like to learn how to create your own tasks, take a look at our task creation guide.

Next, if you take a look at contracts/, you should be able to find Greeter.sol:

To compile it, simply run:

npx buidler compile

Now, you’ll likely want to run some tests. Out of the box Buidler provides an EIP1193-compatible provider, which is the new standard for an Ethereum JavaScript interface, but it can be somewhat rough to use directly. For a fully featured development tool with a nice interface, you’ll need to install one of the core plugins that we’ve built.

These are:

The sample project comes with a test written using the Ethereum provider, but let’s also install buidler-truffle5 and test out the Truffle 5 integration:

npm install @nomiclabs/buidler-truffle5 @nomiclabs/buidler-web3 web3@1.0.0-beta.37

Add require("@nomiclabs/buidler-truffle5") to the top of your buidler.config.js, and let’s change test/sample-test.js to:

And run npx buidler test

You can then deploy by writing a deployment script with the Truffle 5 plugin:

npx buidler run scripts/deploy.js

Congrats! You have created a project, ran a Buidler task, compiled a smart contract, installed a Truffle integration plugin, wrote and ran a test using the Truffle plugin, and deployed a contract.

These cover the basics to start using Buidler. Head over to Github for more guides that cover the more advanced usage that allow your process and dev toolkit to be amazingly flexible.

For any questions or feedback you may have, you can find us in the Buidler Support Telegram group.