[MUSIC] Next we are going to create a folder Ballot1 since we are going to work with several versions of the ballot. Truffle provides a template directory of folder with a required structure. Know that you'll have to run the virtual machine and start a terminal before you issue the commands in a command line. First, create a folder, Ballot1, for your project. Navigate to your workspace folder. In this folder, you will create a directory or folder called Ballot1 by mkdir Ballot1. Then navigate into this ballot directory by cd ballot1. Once you're inside, you're ready to initialize a project. You can do that by using truffle init command. Once truffle init executes, you will see three directories of folders, contracts, migrations, and test. And contracts contains solidity source files for our smart contracts. There is an important contract here called migration.sol, that is the smart contract for facilitating deployment. Migrations folder, Truffle uses a migration system to handle contract deployments. A migration is additional special small contract that keeps track of changes.20. Test directory contains both JavaScript and solidity tests for our smart contract. Next you see truffle.js, the truffle configuration file, that specify the blockchain network ID, IP, and RPC port. We'll now discuss adding contents to the directories that we created and configuring truffle.js environment for the blockchain properties. Okay, let's add ballot.sol to the contracts directory. Review the familiar content of the contract and its functions. Now, change directory back to the root directory of the ballot, and compile using truffle compile. No errors should be present. Hello everyone, let's get started with the demos for course three. We've given you a virtual machine imagine, make sure that you have installed that. And also, you have installed Truffle if you are not using that IDE you've installed. Truffle is the IDE we are going to use in the development of the decentralized app that we are going to create. We are going to create several apps. Also, make sure that you download the code files, the folders and the code snippets, and other file that we have provided in the sources section of course three. I've created a workspace here for coursera and course3. It doesn't have anything at this point, as you can see, and I'm going to keep adding to this folder as we develop several demos. To start with, let's start initializing the template that is needed for the first demo. This demo is about the ballot that we've been using in the second course, course two, and also right here in course three. And I'm going to do that by issuing the command traffic init. That'll create a template for Dapp. It's ready. We can see that by looking at the folder and I have contracts, migration, test, and a couple of script files that I have for configuration. And they may not have anything at this point, so let me just go through and look at the contracts. Contracts folder has one smart contract, as you can see, it's in solidity, that helps in the migration of the smart contracts that we write. And so that's why it's called migration smart contract. Let's go back, and in the migrations, there is a script file that helps in the deployment of the migration.sol that we talked about just now. And let me see, let me go back to full screen here. And we have other files test where there's nothing at this point, but we can add our test script in here. So this is the basic template into which that you are we are going to bring in our Ballot.sol. How do you do it? I'm in the right directory, this is the base directory. And I'm going to copy from our CourseraDocs, that's where I copied all the files from the resources. I'm interested in a smart contract for Ballot, and I'm going to copy that into my contracts folder It's copied right, so let me just go to my contracts folder, make sure it's there. It is there, okay. So what do I do, I go back to my base and now I'm ready to compile. How do I compile? I just use truffle. [INAUDIBLE] do that, it goes through. It compiles the two smart contracts that are in the contracts folder and it creates the build artifacts. And as you can see, it has created a new folder build, and that's where the build artifacts are that the compiler generated. Now let's see whether if we write a smart contract from the scratch and if we make some syntax errors if Truffle compile is able to find out. For that I'm going to use an editor. You can use any editor, Atom, Sublime, but I'm going to use the editor that comes with this, Ubuntu. And I'm going to do that and I'm going to go into, Contracts, and here, and I'm going to g, gedit Ballot.sol,. And I'm putting it in the background so that I can be doing something else when the editor is open. And keep it open as I'm doing the other items in the directory. So I'm going to go here to the register function, this is a familiar smart contract for you. I'm going to remove that semicolon just to introduce an error in this smart contract. You see that it is in the third line, one, two, three, of the register. And you will see that this is the next line and that's going to be creating the syntax error. And I'm going to save it, and let's go back to Ubuntu, and I'm going to go back and just check where I am. I'm going to go back to my base and I'm going to initiate my truffle compile again. I'm going to initiate my truffle compile, And it's going to give me an error. And it says that, expected token semicolon, that's what we removed. And it says before this line there was semicolon expected that was not there. So let's go back to my gedit and correct the error that we introduced here. Put the semicolon back, save it. Come back here, and I can use an up arrow to go back to the previous command and I truffle compile. And now I shouldn't get any errors. So we compiled all right. This is how you compile a smart contract in a Truffle IDE. You can also try editing the ballot also. Remove a semicolon somewhere and repeat the compile process. You will observe that truffle flag syntax errors. You can go back and debug it, save it, and recompile it using truffle compile. A better practice would be to remove any errors using a familiar Remix environment, introduced in the smart contracts course. Recall that Remix has just in time compiler. That compiler can catch syntax errors as you type in the smart contract code. Now we are ready to configure the truffle environment. To do this, replace the empty truffle.js file in the ballot home directly to the one shown here. That sets the configuration of the local blockchain you will deploy next. 9545 is the RPC port for the test chain provided by Truffle. Now we are ready to deploy the local blockchain with Truffle. In a new terminal, navigate to the home of the ballot and deploy the development blockchain. The command is truffle develop. This command will deploy a local test blockchain with ten account addresses that you would see. It'll also display seed words while linking these accounts into a wallet or an interface such as MetaMask that we'll use later. Save the words somewhere, you may also copy the saved words into a file. Just one more additional step. We need to add a file to the migrations directory to deploy our smart contract. Create a new file named 2_deploy_contracts.js in the migrations directory. Add the following content to the 2_deploy_contracts.js file. Here is the content. You can simply copy 2_deploy_contracts.js from the Resources for the course into the migrations folder or directory. Are you ready to deploy the smart contract?