Learn how to install the software needed to develop the application we will build in this course, mainly the Truffle app, but also Ganache and Node.
If you remember, smart contracts don't get compiled on the Ethereum network. They're already compiled bytecode when they exist in the blockchain. So, we're gonna need to be able to compile them and also migrate them, and Truffle is an amazing tool to help us do that, and in addition, it has a built-in test server. I'm also gonna go over installing Ganache. Ganache works side-by-side with Truffle. It's actually optional to use because we have a test server that runs with Truffle. But if you want to, it does provide a nice visual interface.
So, it's basically just an Ethereum test server that you can run with a special GUI that you can use to see what's going on, and see how much eth is at different addresses, and be able to easily visually browse the transactions that are happening. Installing Truffle for both Windows and Mac is the same basic process. It's going to use the node installer NPM. So, in order to do that, you first wanna make sure that you have Node.JS 5 or higher. Let's go ahead and open a terminal.
Okay, so the first thing I wanna do is to simply type in npm install. And that's how we install things. And actually on the Macintosh, I wanna make sure to run sudo because it's gonna need administrative permissions. So, sudo npm install -g truffle. And then it's gonna ask me for my password. That's because I'm running sudo. And you'll see it's gonna do a bunch of things, unpack things. And, you can see, it downloaded and installed everything.
So, to make sure it's installed, I can type in truffle version, and that gives me the version, both of Truffle that I'm using, and the version of Solidity that's available to me. So that's basically it for Truffle. I now have an environment. It's a command line environment where I can do a bunch of things. I'm gonna do testing of my smart contracts, I can run a little testing server, I can actually do building and migrations of my smart contracts.
The other thing that we want to install, and this is optional, but I will show you how to use it in this course, is Ganache. The easiest thing and the easiest way to do this is to simply go to the GitHub and download the correct version for your operating system. And it's a simple executable. You can install it and then you'll be all set and good to go. Once it's downloaded, you can go ahead and launch the installer.
And then I can go in here to make sure it's installed. Double-click it, and, yes, I want to enable it to open. And it's firing up. You can enable or disable analytics. That's really up to you, just like all these things. It can help them with their development. So you can see now I'm set up. It's mining this as my gas price, and here are all my wallets, and it defaults 10 wallets with 100 eth in each of them. So we're set up in there. The last thing I wanted to cover for Windows users are some of these naming conflicts.
So there are a few things you can do. The main thing is truffle.cmd is on the path that's part of NPM, but the configuration file is in a different directory. So, there are a few different workarounds here. You're gonna have to decide which works best for you. So that's basically it. We've got our server all set up. We're ready to start writing some smart contracts.
- How the Ethereum blockchain differs from bitcoin
- What smart contracts are and how they work
- Creating a smart contract from scratch in Solidity
- Using Truffle to test smart contracts
- Using web3.js to interact with the blockchain
- Deploying resources in Swarm