Truffle Suite: A fully prepared blockchain treat, ready to unwrap

Have more questions? Submit a request

One of the most powerful tool sets you have available is the Truffle Suite, which includes the  Truffle and Ganache tools. In fact, there's so much going on in this project that it can be a bit overwhelming at first. Here's a presentation of the different Truffle tools you may want to use, depending on your use case:

 

Building a dapp with a smart contract: Truffle

The tasty goodness at the core of Truffle is a smart contract development environment, helping you to compile, test, and debug smart contracts in the context of how they work with the rest of your app. These essential functions are published in an npm package, which can be used like any other nodejs project. Details and tutorials are laid out in their well-maintained documentation

A well-maintained toolset in a convenient npm package is a great head start, but Truffle goes a step further. To work with Truffle effectively, you'll need to familiarize yourself with their concept of Truffle Boxes. These are pre-made starter kits, boilerplate apps with varying levels of complexity and functionality. Of particular interest are their boxes customized for deploying an app using React, Redux, Angular, Next, Vue, and Webpack.

Truffle Boxes

This is one of the crucial points where the network(s) you end up deploying your dapp to is an important consideration. Truffle offers boxes optimized not only for your development stack, but for your deploy environment as well. They’ve optimized for Optimism, Arbitrum, Filecoin, Polygon, Skale, RSK, Harmony, Moonbeam, blockchains on Azure, and of course Ethereum. They even have boxes prepped for NFT projects and flashloans

If you haven’t thought about this yet, jump to our Network Node for guidance in choosing your network.

Seriously: if you're thinking about building a dapp, there's likely to be a Truffle Box that will save you a lot of time and effort. 

Jump to the Network Node

 

Testing dapps on a local blockchain environment: Ganache

One of web3's core value propositions is that it enables apps and public resources to "pay their own way", rather than relying on business structures that extract value from users' data, and advertisements, etc. This means that 'on-chain' activity has a cost, and this can be a stiff barrier to entry for new developers and projects, as well as users ‘

In other words: it costs money to put your smart contract on chain.

That's where Ganache comes in. It’s a tool that allows you to run a local blockchain with minute control over the specifics, from block issuance to control over addresses to visibility into pending transactions.

Ganache accounts

This gives you the control to test your code against the exact scenarios you're interested in, without spending all your precious resources on deploying one iteration after another of your code to a live network.

 

Reading blockchain data and displaying it reliably: Drizzle

Drizzle, like its name suggest, puts the finishing touches on your dapp's UI. A number of tools are included in Drizzle, which like the core Truffle functionality, is published in its own npm package. The default Drizzle package is built for Redux, and there are React-specific packages as well

Drizzle's libraries provide you with out-of-the box tools, optimized for these frameworks, that help you serve the most up-to-date blockchain data to your UI and your users; for a graphical illustration of how that works, check out their explanation, "How Data Stays Fresh".

 

Integrating Truffle into your workflow: Truffle for VSCode

Truffle VSCode

Most of us aren't building web apps in a terminal window, although hats off to those hardcore few (I know, I know, I hear neovim is great); Truffle's VSCode plugin makes it that much easier to use the power of their tools in a contextual environment. 

That includes the ability to deploy smart contracts to a number of environments, including locally with Ganache, a live network through an RPC endpoint, or even to Hyperledger Besu.

 

Let's recap: 

  • Web3 app development uses familiar Web2 technologies to create dapps 
  • Truffle Suite is an integrated set of tools covering everything needed for a dapp:
    • Smart contract development and debugging (Truffle, Truffle for VSCode)
    • Testing the code on a local, custom blockchain environment (Ganache)
    • Deploying it to public testnet and mainnets (Truffle)
    • Ready-made, optimized UI frameworks (Drizzle)


What comes next? As a developer, you need to know how your users are going to be able to access, and interact with, your app. For the vast majority of users, the answer to that question is simple: MetaMask.

Articles in this section

Was this article helpful?
0 out of 0 found this helpful
Share