This third course of the Blockchain specialization prepares you to design and develop end-to-end decentralized applications (Dapps) – which provide anyone with access to the blockchain’s features and services. You will use Truffle IDE, smart contracts, a simple web client and a MetaMask client. You will learn about the architecture of a Dapp: the front-end client interface, backed by the blockchain and smart contracts. The course covers the basic design of a Dapp, Truffle development process and commands (init, develop, test and migrate), test-driven development of Dapp, Dapp application models and emerging standards that are essential for predictable Dapp behavior.
Main concepts are delivered through videos, demos and hands-on exercises.

DM

The course structure is concise yet insightful in nature. It allows you to explore, experiment and learn through that process.

MI

Mar 25, 2019

Filled StarFilled StarFilled StarFilled StarFilled Star

Very nice course, I learned how to program in solidty and testing by writing JS code.

À partir de la leçon

Truffle Development

We'll explore the user-friendly environment that Truffle provides for developing and testing a Dapp. We'll explore further the truffle commands such as: develop, init, compile, migrate, test - all with truffle in front of them and with any parameters. This module will illustrate the steps needed in developing and testing a complete Dapp.

Enseigné par

Bina Ramamurthy

Teaching Professor

Transcription

[MUSIC] Once again from the base directory of the ballot, issue the command Truffle, migrate, dash dash, recent. On execution you will see Saving successful migrations to network with a valid contract name. Also, you will see the message Saving artifacts. These are indeed artifacts that were generated by the compile process we examined in Course two. Dash dash, reset is to ensure that the new version of the smart contract is deployed, resetting the older version that you may have on the block chain. >> You have successfully compiled the ballot that's sold our smart card, right? Using Truffle ID. Now we are ready to deploy it or migrate it onto a test chain. The test chain has to be deployed first before we can deploy the smart contract on it. So let's do that. In order to do that, just observe in our folder, we have a truffle.js that is the configuration for our test chain. There's nothing. So in order to get something into this, we're going to copy from our Coursera Docs. truffle.js we have readily provided you a configuration card. And let's look at it now. I copied it, and let's look at it now. It's got some details about what the host IP is and what the port number through which its going to connect to the web application and the network ID itself. So now let's, I'll clear that, and let's deploy this test chain. In order to do that I'm going to go into another term, a new term, and then I'm going to go into the same folder that, where I have my truffle.js. And you can see that's my base directory, and here I'm going to do truffle development. And that will deploy a test chain for me with 10 accounts, addresses as you can see account 0 to account 9 and also the private keys for those private keys are 256 bits. And the addresses are, we know from our course one, that are 160 bits. It also gives you seed words. Make sure that you copy and keep it, at some point when we are doing the testing, we may need this for connecting to this test chain. So our chain is ready, now we are ready to migrate or deploy our smart compile smart contract into this. In order to deploy, we need one more file, and I'm going to copy that file to, Set our docs again to deploy. This is one, this is a file that goes into Migrations folder, and it will help us deploy our contracts into it. So let's see what is in this file. And you can see that it's got, it says that you, the files to be deployed, the smart contract to be deployed is valid. And now let's go back. And we are now ready to deploy. So how do you deploy the smart contract? By using truffle? Of course migrate. And when I do that I won't use minus minus reset every time. Remember, this is development phase so we can overwrite the previous smart contract if you're not satisfied with the previous version of smart contract that you deployed. This is only for development. Once you go to production, once you deploy the smart contract you cannot change it. Here I'm resetting in any previous ballot that I might have deployed. So truffle migrate minus minus reset, dash dash reset. That will deploy the compiled smart contract. You can see that this uses the network development that we created just now. And it deploys the initial migration that is for the base migration, and then it deploys the valid contract that we compile. And it also saving the artifact that we'll use later on as we connect it to the. >> Congratulations, you have deployed your ballot smart contract on the test blockchain that Truffle provided. The truffle develop command that you executed earlier on a different terminal opened up a console for you. What can you do with the Truffle console? The console provides a command line interface to the accounts created on the test chain and also to the management APIs we discussed earlier in Module 1. Here are a few commands to transfer ethers between accounts, illustrating the power of command line. We are also testing the Truffle test chain by sending a transaction from one account to another and checking the balance of the sender. In summary, in this lesson we introduce the ballot problem to illustrate the Dapp development process on Truffle. We introduced the Truffle IDE commands. Remember, Truffle is already pre-installed on the VM from course one. We also discussed the directory structure for DApp developed on Truffle IDE. We concluded with of the development and deployment of a smart contract. In the next lesson, we learn to test this marker correctly.