Learn blockchain development tutorial

By | Thursday, April 15, 2021

Navigation

  • Get started with blockchain development
  • Blockchain Tutorial: Learn Blockchain Technology (Examples)
  • Learn step-by-step how to set up a basic blockchain network
  • Build a Zombie Army
  • Get started with blockchain development

    In public blockchains, anyone can see all the operations within the network, learn blockchain development tutorial, and in private blockchains, only specified development approved users can tutorial full access to operations within the network. By using the Blockchain technology, beneficiaries received blockchain, food development all type of transactions are registered on a blockchain to ensure security and transparency of this process. Or try less traditional ways like studying blockchain online on learning platformsjoining blockchain communities, participating in forums and learn about learn, and trying to invest in crypto by yourself. First, create a blockchain component called code Tutorial. Instead of a bank storing all this data inside a central database, the blockchain stores it redundantly on each node in the network.

    Learn blockchain development tutorial

    Initially created as a platform for supporting Bitcoin, Blockchain is demonstrating a level of versatility and security that has made many sectors of business and government take notice and begin putting it to their use.

    If this prospect intrigues you, and you want to know how to become a Blockchain developer, then read on and find out all you need to know about this exciting and intriguing profession.

    The wise yet short answer to this is: a Blockchain developer develops Blockchains! Well, that was easy! Call them sub-divisions of Blockchain development. A Core Blockchain Developer designs the security and the architecture of the proposed Blockchain system.

    In essence, the Core Blockchain Developer creates the foundation upon which others will then build upon. That would be the Blockchain Software Developers, of course, who use the core web architecture built by the Developer to create apps, specifically the decentralized dapps and web varieties.

    Perhaps there may be situations where the same person fulfills both roles, most likely in cases where the business is small, and people traditionally wear more than one hat. Whatever the case, the everyday responsibilities and roles of the Blockchain developer are:. The developer also performs complex analysis, design, development, testing, and computer software debugging, specifically for distinct product hardware or for technical service lines of businesses. Develops perform software design, operating architecture integration, and computer system selection.

    Finally, they operate on multiple systems and apply knowledge of one or more platforms and programming languages. Of course, obstacles are awaiting the Blockchain developer.

    For instance, the developer has to work with legacy infrastructure and its limitations, while still meeting the expectations inherent in a Blockchain development project. Also, there are the challenges of understanding the technical practicality of implementing decentralized cryptosystems, processes that fall outside of the traditional IT development skill-set, which means a Blockchain developer needs specialized skills.

    So, after all of that, the questions present itself: with all of these responsibilities, how does one train someone with the necessary skills to let them rise to the challenge of Blockchain development?

    There are two different situations at work here. There are the Blockchain hopefuls who are starting completely from scratch, having no background in programming whatsoever, and those who have experience in careers that share similarities with Blockchain. Before we dive into those two different types of people aspiring to become Blockchain developers, it may help to familiarize ourselves with the kind of mindsets that are best suited for Blockchain developers.

    After all, the unique challenges of Blockchain development require a certain unique way of thinking. Furthermore, a good Blockchain developer works well with a team and can collaborate. On a related point, the ideal Blockchain developer knows when to ask for help with a problem and when to keep plugging away by themselves until they arrive at the answer.

    So the best candidate for Blockchain development works well with others, knows his or her limitations, and can unconventionally approach problems. Skip to main content. Contents Exit focus mode. Table of contents. Get started with blockchain development Learning Path 6 Modules. In this learning path, you will: Learn the foundations of blockchain and how blockchain technology works. Gain an understanding of the tools to develop on the Ethereum blockchain. Create smart contracts and decentralized applications.

    Deploy to local and test Ethereum networks. Prerequisites Previous experience with any programming language like C, Python, or JavaScript Basic knowledge of programming concepts Familiarity with the command line to create new directories Visual Studio Code installed. Bookmark Add to collection. Modules in this learning path. Introduction to blockchain on Azure.

    Learn how to use Solidity.

    Blockchain Tutorial: Learn Blockchain Technology (Examples)

    As we write the Solidity code, we will simultaneously write tests for the smart contract with JavaScript inside a separate file with for a few reasons:. Inside this file, we can scaffold a test for the smart contract with the help of the Mocha testing framework and the Chai assertion library that comes bundled with the Truffle framework. Let's start off with this basic code:. This code should look very similar to the operations we performed inside the console from the previous section.

    Check out the companion video for a more detailed explanation of this test. Now that the test suite is set up, let's continue developing the smart contract. We'll program a way for users to create new posts in the social network. Finally, we use the public modifier to ensure that we can call the function outside the smart contract, i.

    Next, we need a way to model the post. We'll use a Struct for this. Solidity allows us to define our own data structures with Structs. In our case, we'll define a Post struct like this:. This struct allows us store the post's id, content, tip amount, and author.

    We declare the data type for each of these values in the code above. Next, let's create a way to store new posts on the blockchain.

    We'll use a Solidity mapping to do this:. This mapping will uses key-value pairs to store posts, where the key is an id, and the value is a post struct. These mappings are a lot like associative arrays or hashes in other programming languages. Whenever we add new posts to the mapping, they will be stored on the blockchain. Because we used the public modifier we can also fetch posts by calling the posts function, which Solidity will create behind the scenes.

    We will increment this value whenever new posts are created to generate post ids we'll see that in action momentarily. I will also note that we use msg. This is a special variable value provided by Solidity that tells us the user who called the function. We don't have to pass this value in as a function argument. We get it magically with Solidity. Now, let's trigger an event whenever the post is created. Solidity allows us to create events that external consumers can subscribe to like this:.

    Lastly, let's add a validation to ensure that users can't post blank content. We'll do that in the first line of our function like this:. This uses Solidity's require to ensure that the post has content before the rest of the code executes. If the expression inside require evaluates to true, the function will continue execution.

    If not, it will halt. That's it! That's the complete code for creating new posts. At this point your smart contract code should look like this:. Now, let's add some test examples to ensure that this function works. Add this code to your test file:. Also, we modified the test suite to include 3 different users: deployer , author , and tipper.

    We can do this instead of using the accounts variable that was injected by default. In this section, we'll create a function that allows users to tip others post with cryptocurrency. Before we do that, let's address a few things. Any time we store data on the Ethereum blockchain, we must pay a gas fee with Ether Ethereum's cryptocurrency.

    This is used to pay the miners who maintain the network. Since we stored a new post on the blockchain, a small fee was debited from our account. You can see that your account balance has gone down in Ganache. While storing data on the blockchain costs money, fetching does not. In summary, reads are free, but writes cost gas.

    Next, we need to add a test to ensure that we can list out all of the posts from the social network. Inside your test file, use this code:. Now let's move on to creating a function that allows other users to tip posts with cryptocurrency:. This function accepts the post id as its only argument. Note, that we use a new modifier called payable. This allows us to send cryptocurrency whenever we call this function. This uses function metadata instead of passing in cryptocurrency as a function argument.

    That's the basic tipping functionality. Let's do a few more things before we finish this function. Finally, let's add a validation that the post exists in the first line of the function like this:. Let me explain how this test works. First, we ensure that the author receives a tip through this 3-step process:. In this scenario, the tipper sends 1 Ether to the author. However, you see a very large value of '' in the test.

    This is the "wei" value which is equal to 1 Ether. Wei is like Ethereum's penny a very small penny. We must use the wei value because Solidity smart contracts do not support fractional cryptocurency.

    We must represent all cryptocurrency values as wei inside the smart contracts. Luckily, the web3. Finally, we pass this value into the function metadata with the value key to specify the amount of crypocurrency we want to send like this:.

    Last but not least, let's deploy the completed smart contract to the Ganache development blockchain so that we can start building out the client side application in the next section:. Note: we use the -- reset flag here to deploy a new copy of the smart contract to the blockchain. Remember, we cannot update smart contract code once it's deployed to the blockchain.

    We can only deploy a new copy. That's exactly what we did here. Now let's start begin building the website for the social network. Here is what we'll accomplish in this section:. This is file contains a React. Let me explain why we're using React. We need a way to code all of the client side behavior of our social network website, and interact with the blockchain. Instead of writing all of this by hand, React gives us this ability by organizing all of our code inside of reusable components.

    It also gives us a way to manage the application state with the React state object. Let's modify this code to connect the app to the blockchain. We'll do this with the Web3. We already installed in from our package. All we need to so is import it at the top of our file like this:. This code detects the presence of an Ethereum provider in the web browser, provided by Metamask more on that momentarily. These are the exact instructions that Metamask gives us for loading web3 in our app.

    Don't worry if you don't fully understand this. That's okay! We're simply following the default pattern. Next, let's import our accounts from Ganache into Metamask. You can watch me do this on screen step-by-step at this point in the video.

    Next, we'll store the account in React's state object for later use. First, we'll define a default state for this component like this:. Now let's display the account on the page. I'm going to create a new React component for the Navbar that will make this much easier. First, create a new component called code Navbar. Add this code to the file:. I'll point out that this component reads the account with this. This makes use of React's props object, which is native to all React components.

    We will pass these props down to the navbar component momentarily. Now let's render out the navbar on the page. Delete all the old navbar code, and replace it with this:. Notice that we first fetch the account from state, and pass it down as the account prop when we render the component.

    That's what allows us to read its value with this. We'll use Identicon. This will allow us to automatically generate unique avatars for our users based upon their Ethereum address. Let's start by adding the Identicon library to the "dependencies" section our package.

    Because we installed a new library, we must restart our server. After you've stopped it, restart it like this:. Now let's add the identicons.

    First, we must import the new library at the top of our Navbar component like this:. Now, we can update the navbar code to render out the Identicon on the page.

    Replace all the code inside your render function with this:. In order to do this, we need some post! Let's create one inside the truffle console. First, we'll open it like this:. We must first import our smart contract into the React app. Do this at the top of the App. This imports the smart contract ABI file that was generated by Truffle whenever we deployed the smart contract to the blockchain.

    This file contains a JSON description of how our smart contract works, like the kinds of functions it has and their arguments. It also tracks the address of the smart contract on the blockchain. We'll use both of these pieces of information to create a JavaScript version of the smart contract so that we can use it our app. You can watch this part of the video for an in-depth explanation of this file's contents.

    Now we have a JavaScript version of the smart contract. Now we can call its functions inside the client side app. Let's demonstrate that by loading all of the posts into our app so that we can list them on the page like this:. In order to do this, a new component for all the page content inside the components directory called Main.

    This code loops through all the posts contained in this. Now let's include this component back in our App. Lastly, we'll add a loader that will show when the page is still loading blockchain data like this:. We can track the loading status on inside the React state object.

    We'll set it to true by default:. In order for this form to work, we must create a function inside the App. Finally, we'll pass the function down to the Main component so that it can be called in the form:. Now let's add the corresponding tipPost function in the App. You have just completed your first full stack blockchain application. Now you have an in depth understanding of how blockchain works as a developer. Happy with this tutorial? Then you NEED to join my free training here where I'll show you how to build a real world blockchain app so that you can become a highly paid blockchain developer!

    Check out this list of awesome tutorials below. Table of Contents 1. Introduction 1. Tutorial Steps 2. What Is Blockchain? A blockchain is an immutable distributed ledger of transactions that stores value across a peer-to-peer network.

    Blockchain Vs Cryptocurrency Bitcoin is a cryptocurrency, but blockchain is the underlying technology behind Bitcoin. How Does Blockchain Work? Blockchains store all their transactions into bundles of records blocks which are chained together to make an immutable distributed ledger.

    Click Associate identity. It associates the CA admin identity with the CA node. You can change the identity display name or proceed with the default name provided. Click Register user , and then register an admin for your organization. Set the type for this identity as admin. This identity works as an organization admin and allows you to operate nodes using the console. The remaining attribute, Maximum enrollments , is optional.

    Leave it blank and click Next. Next, it asks you to add attributes. This is used for role-based access control over resources. For the purpose of this tutorial, you do not need to use attributes. Click Register user. Repeat Steps 1 — 4 to register one more user with a peer type identity. This identity allows you to deploy a peer. Admin certificates : Select the enroll ID that you created for your organization as admin identity for example, org1admin.

    Provide the enroll secret and identity name. Click Generate. It generates the identity as the admin for your organization and adds it to your Wallet. To avoid losing these public and private keys, export them now and click Next. Finally, click Create MSP definition. Navigate to the Nodes tab, click Add peer , choose Create a peer , and then click Next. Provide a peer display name, leave advanced deployment options with the default value, and click Next. On the next screen, select the CA that you created in Step 4.

    Select the enroll ID of the peer identity that you created for your peer at the end of Step 5 and provide the associated secret. On the next screen, you are asked to associate an identity to make it admin of your peer.

    For the purpose of this tutorial, you can choose the organization admin org1 msp admin , and then click Next. Review the summary and click Add Peer. To add more peers in the same organization, register a new user with peer identity as mentioned in Step 5 and repeat this step. Note: Repeat Steps 4 — 7 to create more organizations and peers as needed. The orderer node runs the communication service that guarantees transaction delivery in the network. To create the orderer, you need to create the orderer CA first.

    Perform the same steps that you did in Step 4 to create the orderer CA. Next, register the orderer user identities using your orderer CA.

    Perform all of the steps in Step 5 again to register users with admin and orderer identities. Create the orderer MSP definition in the same way that you did in Step 6. Navigate to the Nodes tab and click Add ordering service. Choose Create an ordering service and click Next. Provide the Ordering service display name and you can designate the Number of ordering nodes as one ordering node.

    One ordering node is suitable for development and testing. Then click Next. Provide the required information as explained in Step 7, but make sure you choose the correct orderer CA and orderer MSP.

    Click Next. The channel is the mechanism through which a set of components within a blockchain network communicate and transact. Navigate to the Channels tab in the left navigation and click Create channel. In Channel details , provide a name for the channel. Select the orderer you created from the Ordering service drop-down list.

    Now add organizations to the channel. Repeat this step to add all of the required organizations to your channel. Choose the appropriate channel update policy from the available options and click Next. Next is the channel creator organization. Select the Channel Creator MSP , identifying an organization for channel creation from the drop-down list. Then associate an available admin identity for that organization and click Next. If you have any files in this folder other than smart contract files, then you might encounter issues while packaging the smart contract.

    Press the F1 key to see the various VS Code options. Make sure Node, NPM, and Go are installed and the corresponding paths are set before you perform this step.

    Learn step-by-step how to set up a basic blockchain network

    Learn blockchain development tutorial

    Step 4 Once tutorial transaction is complete the new block is then added development the existing learn. Their keyword is int. It will enable us to develop tutorial contracts, blockchain tests against blockchain, and deploy them to the blockchain. This is what is provided by distributed ledger technology. The technique is intended to timestamp digital documents so learn it's not possible to backdate them or temper them. Table of Development 1. How Does Blockchain Work?

    Build a Zombie Army

    Find the latest release for your operating system here. The next dependency is the Truffle Framework , which gives us a suite of tools for developing blockchain applications. It will enable us to develop smart contracts, write tests against them, and deploy them to the blockchain.

    Now let's install the Metamask Ethereum Wallet in order to turn our web browser into a blockchain browser. Your current web browser most likely doesn't support this natively, so we need the Metamask extension for Google Chrome in order to connect to the blockchain. Visit this link to install Metamask, or simply search for it in the Google Chrome web store.

    Upon installation, ensure that you've enabled it in your list of Chrome extensions it should be "checked". When it's active, you will see a fox icon in the top right hand corner of your browser. Find where you installed Ganache, and open it. Once it's loaded, you have a blockchain running on your computer! You should see 10 accounts provided by Ganache, each pre-mined with fake Ether don't get excited, this Ether isn't worth real money.

    Each account has a unique public and private key pair. You can see each account's address on the main screen here. Remember, accounts are much like "usernames" on the blockchain, and they represent each user who can post to our social network.

    Now let's create a new project for all of our application code. Instead of doing this from scratch, I'm going to use a template that I created to help us get started quickly. You can clone this template from github like this:. Open the project in your text editor of choice, and find the truffle-config.

    This is where we will store all of the settings for our Truffle project. I have already configured the project to connect to the Ganache development blockchain on I have changed this from the default Truffle project configuration so that we can access these files from our front end application in the src directory. These values are normally. This file contains all of the project dependencies we need to build the application. I have included all the dependencies we need inside this starter kit template.

    If you did everything correctly, your web browser should open automatically to a page that looks like this:. You've just set up the project. This is all of the template code that we will modify to create our app. Now, let's code the smart contract to power the backend of the social network app. It will allow users to create new posts so that they can be shared in the newsfeed and tipped by other users.

    This is the file where we'll write all the Solidity source code for the smart contract just a reminder, this is inside a custom src directory, which is different from a default truffle project. Let's create a simple "systems check" to ensure that our project is set up properly, and that we can deploy this smart contract to the blockchain successfully. Start by entering this code into the SocialNetwork.

    I'll explain this code. The first line declares the Solidity programming language version that we'll use, i. Next, we create the smart contract with the contract keyword, followed by the smart contract name Social Network. Next, we define a state variable that will represent the name of our smart contract.

    This state variable's value will get stored directly to the blockchain itself, unlike a local variable which will not. We specify that this variable is a string. We must do this because Solidity is a statically typed language, meaning once we specify that this variable is a string, it cannot be a different data type later like a number.

    Then we declare the state variable public with a modifier. This tells Solidity that we want to read this variable value from outside the smart contract. Because we have done this, Solidity will automatically create a name function behind the scenes that will return this variable's value we won't have to code it ourselves.

    Finally, we create a constructor function with the constructor keyword. This is a special function that gets called only once whenever the smart contract is created, i.

    Inside this function, we set the value of the name state variable to "Dapp University Social Network". In order to do this, we must create a new migration file. Truffle uses these migrations to add new files to the blockchain. These are similar to migration files in other development frameworks where you make changes to a database, like adding new columns in tables.

    This code simply tells Truffle that we want to deploy the Social Network smart contract to the blockchain. Don't worry if you don't understand everything inside this file. Now let's put this smart contract on the blockchain i. Ganache by running the migrations from the command line like this:. Inside the console, we can write JavaScript code to interact with our development blockchain and smart contracts. Let's fetch an instance of the deployed social network smart contract and store it to a variable like this:.

    You'll see that the console returns undefined here. That's ok. We simply need to enter the variable name to return is value like this:. You have just coded your first smart contract and deployed it to the Ethereum blockchain. Let's continue building out the smart contract. As we write the Solidity code, we will simultaneously write tests for the smart contract with JavaScript inside a separate file with for a few reasons:. Inside this file, we can scaffold a test for the smart contract with the help of the Mocha testing framework and the Chai assertion library that comes bundled with the Truffle framework.

    Let's start off with this basic code:. This code should look very similar to the operations we performed inside the console from the previous section. Check out the companion video for a more detailed explanation of this test.

    Now that the test suite is set up, let's continue developing the smart contract. We'll program a way for users to create new posts in the social network. Finally, we use the public modifier to ensure that we can call the function outside the smart contract, i. Next, we need a way to model the post. We'll use a Struct for this. Solidity allows us to define our own data structures with Structs.

    In our case, we'll define a Post struct like this:. This struct allows us store the post's id, content, tip amount, and author. We declare the data type for each of these values in the code above. Next, let's create a way to store new posts on the blockchain.

    We'll use a Solidity mapping to do this:. This mapping will uses key-value pairs to store posts, where the key is an id, and the value is a post struct. These mappings are a lot like associative arrays or hashes in other programming languages. Whenever we add new posts to the mapping, they will be stored on the blockchain.

    Because we used the public modifier we can also fetch posts by calling the posts function, which Solidity will create behind the scenes. We will increment this value whenever new posts are created to generate post ids we'll see that in action momentarily. I will also note that we use msg.

    This is a special variable value provided by Solidity that tells us the user who called the function. We don't have to pass this value in as a function argument. We get it magically with Solidity. Now, let's trigger an event whenever the post is created. Solidity allows us to create events that external consumers can subscribe to like this:.

    Lastly, let's add a validation to ensure that users can't post blank content. We'll do that in the first line of our function like this:. This uses Solidity's require to ensure that the post has content before the rest of the code executes.

    If the expression inside require evaluates to true, the function will continue execution. If not, it will halt. That's it! That's the complete code for creating new posts.

    At this point your smart contract code should look like this:. Now, let's add some test examples to ensure that this function works. Add this code to your test file:. Also, we modified the test suite to include 3 different users: deployer , author , and tipper. We can do this instead of using the accounts variable that was injected by default. In this section, we'll create a function that allows users to tip others post with cryptocurrency.

    Before we do that, let's address a few things. Any time we store data on the Ethereum blockchain, we must pay a gas fee with Ether Ethereum's cryptocurrency.

    This is used to pay the miners who maintain the network. Since we stored a new post on the blockchain, a small fee was debited from our account. You can see that your account balance has gone down in Ganache. While storing data on the blockchain costs money, fetching does not. In summary, reads are free, but writes cost gas. Next, we need to add a test to ensure that we can list out all of the posts from the social network.

    Inside your test file, use this code:. Now let's move on to creating a function that allows other users to tip posts with cryptocurrency:.

    This function accepts the post id as its only argument. Note, that we use a new modifier called payable. This allows us to send cryptocurrency whenever we call this function. This uses function metadata instead of passing in cryptocurrency as a function argument.

    That's the basic tipping functionality. Let's do a few more things before we finish this function. Finally, let's add a validation that the post exists in the first line of the function like this:. Let me explain how this test works. First, we ensure that the author receives a tip through this 3-step process:. In this scenario, the tipper sends 1 Ether to the author.

    However, you see a very large value of '' in the test. This is the "wei" value which is equal to 1 Ether. Wei is like Ethereum's penny a very small penny. We must use the wei value because Solidity smart contracts do not support fractional cryptocurency.

    We must represent all cryptocurrency values as wei inside the smart contracts. Luckily, the web3. Finally, we pass this value into the function metadata with the value key to specify the amount of crypocurrency we want to send like this:. Last but not least, let's deploy the completed smart contract to the Ganache development blockchain so that we can start building out the client side application in the next section:.

    Note: we use the -- reset flag here to deploy a new copy of the smart contract to the blockchain. Remember, we cannot update smart contract code once it's deployed to the blockchain. We can only deploy a new copy. That's exactly what we did here. Now let's start begin building the website for the social network. Here is what we'll accomplish in this section:. This is file contains a React. Let me explain why we're using React.

    We need a way to code all of the client side behavior of our social network website, and interact with the blockchain. Instead of writing all of this by hand, React gives us this ability by organizing all of our code inside of reusable components. It also gives us a way to manage the application state with the React state object. Let's modify this code to connect the app to the blockchain. We'll do this with the Web3. We already installed in from our package. All we need to so is import it at the top of our file like this:.

    This code detects the presence of an Ethereum provider in the web browser, provided by Metamask more on that momentarily. These are the exact instructions that Metamask gives us for loading web3 in our app. Don't worry if you don't fully understand this. That's okay! We're simply following the default pattern.

    Half code-school, half MMO crypto-collectible strategy game. What are you waiting for? Click the button below to dive into lesson 1 and build your first DApp. It's free! Powered by Loom Network - a platform for building commerical scale apps on Ethereum. Perfect for absolute beginners, we walk you through basic concepts all the way to building your first DApp. No coding experience needed. Start Course. As long as you have some basic coding experience, you'll be a master of Solidity with only this course.

    Interactive Coding Lessons In-browser step-by-step lessons take you from the very basics of Solidity to creating your own fully-functional blockchain-based game. Earn crypto-collectible Zombies and bonuses by completing coding lessons. Get Started Now.

    How To Become A Blockchain Developer From Scratch! 🚀

    I will also note that we use msg. This is sensitive data stored inside her Bitcoin wallet, which she will not share with development else. To add more peers in the same organization, learn blockchain development tutorial, register a new user with peer identity as mentioned in Step 5 learn repeat this step. Decentralized: There are standards rules on how every node exchanges the blockchain information. Also, what is Ether and how does it differ from other cryptocurrencies? Let's start by adding the Identicon library to the "dependencies" section our package. Tutorial must use the wei value because Solidity blockchain contracts do not support fractional cryptocurency.

    Leave a Reply

    Your email address will not be published. Required fields are marked *