{"id":39018,"date":"2019-10-31T22:27:25","date_gmt":"2019-10-31T19:27:25","guid":{"rendered":"https:\/\/prohoster.info\/blog\/kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo\/"},"modified":"2019-10-31T22:27:25","modified_gmt":"2019-10-31T19:27:25","slug":"kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/news\/kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo","title":{"rendered":"The book \"Creating Smart Contracts with Solidity for the Ethereum Blockchain: A Practical Guide\"","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"The book &quot;Creating Smart Contracts with Solidity for the Ethereum Blockchain: A Practical Guide&quot;\" src=\"\/wp-content\/uploads\/2019\/10\/9549e708e99fef6892045ff854231fa7.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nFor over a year, I worked on the book \u201cCreating Solidity Smart Contracts for the Ethereum Blockchain: A Practical Guide,\u201d and now this work is complete, and the book <noindex><a rel=\"nofollow\" href=\"https:\/\/www.litres.ru\/aleksandr-frolov-198\/sozdanie-smart-kontraktov-solidity-dlya-blokcheyna-et\/\">has been published and is available on LitRes<\/a><\/noindex>.<\/p>\n<p>I hope my book will assist in quickly getting started with Solidity smart contracts and DApp development for the Ethereum blockchain. It consists of 12 lessons with practical tasks. By completing them, readers will be able to set up their own local Ethereum nodes, deploy smart contracts, call their methods, and exchange data between the real world and smart contracts using oracles, while also working with the Rinkeby test debugging network. <\/p>\n<p>The book is aimed at everyone interested in advanced blockchain technologies who wants to quickly acquire the knowledge necessary for engaging in exciting and promising work.<\/p>\n<p>Below you will find the table of contents and the first chapter of the book (also on <noindex><a rel=\"nofollow\" href=\"https:\/\/www.litres.ru\/aleksandr-frolov-198\/sozdanie-smart-kontraktov-solidity-dlya-blokcheyna-et\/\">LitRes<\/a><\/noindex> fragments of the book are available). I hope to receive feedback, comments, and suggestions. I will consider all of this while preparing the next edition of the book.<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\n<b class=\"spoiler_title\">Table of Contents<\/b><b class=\"spoiler_title\">Introduction<\/b>Our book is intended for those who want not only to understand the principles of the Ethereum blockchain but also to gain practical skills in developing DApps using the Solidity programming language for this network.<\/p>\n<p>It's better to work with this book rather than just read it, completing the practical tasks described in the lessons. You will need a local computer, a virtual or cloud server with Debian or Ubuntu OS installed. Many tasks can also be performed on a Raspberry Pi.<\/p>\n<p><b>In the first lesson <\/b>we will explore the principles of the Ethereum blockchain and the main terminology, as well as discuss where this blockchain can be used. <\/p>\n<p>The goal <b>the second lesson<\/b> is to create a node of a private Ethereum blockchain for further work in this course on an Ubuntu and Debian server. We will examine the features of installing essential utilities, such as geth, which enables the operation of our blockchain node, as well as the decentralized data storage daemon swarm.<\/p>\n<p><b>The third lesson<\/b> will teach you how to experiment with Ethereum on a low-cost Raspberry Pi microcomputer. You will install the Rasberian operating system (OS) on your Raspberry Pi, the Geth utility that allows for blockchain node operation, and the Swarm decentralized storage daemon.<\/p>\n<p><b>Lesson Four<\/b> is dedicated to accounts and cryptocurrency units on the Ethereum network, as well as methods for transferring funds from one account to another using the Geth console. You will learn how to create accounts, initiate fund transfer transactions, check the state of transactions, and obtain their receipts.<\/p>\n<p><b>In Lesson Five<\/b> you will get acquainted with smart contracts on the Ethereum network and learn how they are executed by the Ethereum virtual machine. <\/p>\n<p>You will create and publish your first smart contract in a private Ethereum network and learn how to call its functions. For this, you will use the Remix Solidity IDE development environment. Additionally, you will learn how to install and use the solc batch compiler.<br \/>\nWe will also discuss the so-called Application Binary Interface (ABI) and teach you how to use it.<\/p>\n<p><b>Lesson Six<\/b> is dedicated to creating JavaScript scripts that run under Node.js and perform operations with Solidity smart contracts.<\/p>\n<p>You will install Node.js on Ubuntu, Debian, and Rasberian, write scripts to publish smart contracts on a local Ethereum network and call their functions. <\/p>\n<p>Moreover, you will learn how to transfer funds between regular accounts and deposit them into smart contract accounts using scripts.<\/p>\n<p><b>In Lesson Seven<\/b> you will learn how to install and use the popular Truffle Integrated Development Environment (IDE) among smart contract developers. You will create JavaScript scripts that call contract functions using the truffle-contract module and test your smart contract with Truffle tools.<\/p>\n<p><b>Lesson Eight<\/b> is dedicated to Solidity data types. You will write smart contracts that work with data types such as signed and unsigned integers, signed numbers, strings, addresses, complex type variables, arrays, enumerations, structures, and dictionaries.<\/p>\n<p><b>In Lesson Nine<\/b> You will take another step toward creating smart contracts for the Ethereum mainnet. You will learn to deploy contracts using Truffle in a private Geth network, as well as in the Rinkeby test network. Debugging a smart contract in the Rinkeby network is very useful before its deployment to the mainnet\u2014everything there is almost real, but for free.<\/p>\n<p>In this lesson, you will create a Rinkeby test network node, fund it, and deploy a smart contract.<\/p>\n<p><b>Lesson 10<\/b> is dedicated to distributed data storage in Ethereum Swarm. By using distributed storage, you save on storing large volumes of data in the Ethereum blockchain. <\/p>\n<p>In this lesson, you will create a local Swarm storage, perform read and write operations for files and directories. Next, you will learn to work with the public Swarm gateway, write scripts to access Swarm from Node.js, and use the Perl module Net::Ethereum::Swarm.<\/p>\n<p><b>The goal of Lesson 11<\/b> is to master working with Solidity smart contracts using the popular programming language Python and the Web3.py framework. You will install this framework, write scripts for compiling and deploying a smart contract, as well as for calling its functions. During this, Web3.py will be used both independently and in conjunction with the integrated development environment Truffle.<\/p>\n<p><b>In Lesson 12<\/b> you will learn to pass data between smart contracts and the real world using oracles. This will be useful for retrieving data from websites, IoT devices, various instruments and sensors, and for sending data from smart contracts to these devices. In the practical part of the lesson, you will create an oracle and a smart contract that obtains the current exchange rate of USD to rubles from the Central Bank of Russia's website.<\/p>\n<p><b class=\"spoiler_title\">Lesson 1. A Brief Overview of Blockchain and the Ethereum Network<\/b><b>The goal of the lesson:<\/b> to familiarize yourself with the principles of how the Ethereum blockchain works, its areas of application, and key terminology.<br \/>\n<b>Practical tasks:<\/b> none are provided in this lesson.<\/p>\n<p>Today, it is hard to find a software developer who has not heard of blockchain technology, cryptocurrencies, Bitcoin, initial coin offerings (ICO), smart contracts, and other concepts and terms related to blockchain.<\/p>\n<p>Blockchain technology opens up new markets and creates job opportunities for programmers. If you master all the intricacies of cryptocurrency technologies and smart contracts, you should have no trouble applying this knowledge in practice.<\/p>\n<p>It should be noted that there are many speculations surrounding cryptocurrencies and blockchains. We will set aside discussions about the fluctuations in cryptocurrency prices, pyramid schemes, the nuances of cryptocurrency legislation, etc. In our course, we will mainly focus on the technical aspects of applying smart contracts on the Ethereum blockchain and developing so-called decentralized applications (DApps).<\/p>\n<h3>What is Blockchain<\/h3>\n<p>\nBlockchain is a chain of data blocks that are interconnected in a specific way. At the beginning of the chain is the first block, known as the genesis block.<\/p>\n<p>All these data blocks are automatically replicated across numerous nodes in the blockchain network. This ensures decentralized storage of blockchain data. <br \/>\nYou can think of a blockchain system as a large number of nodes (physical or virtual servers) connected in a network, replicating every change in the chain of data blocks. It's like a giant multi-server computer, where the nodes of such a computer (servers) can be scattered all over the world. And you can also add your computer to the blockchain network. <\/p>\n<h4>Distributed Database<\/h4>\n<p>\nBlockchain can be seen as a distributed database replicated across all nodes in the blockchain network. In theory, the blockchain will continue to function as long as at least one node is operational, storing all blockchain blocks.<\/p>\n<h4>Distributed Ledger of Data<\/h4>\n<p>\nBlockchain can be viewed as a distributed ledger of data and transactions. Another name for such a ledger is a ledger book. <\/p>\n<p>In a distributed ledger, data can be added but cannot be modified or deleted. This impossibility is achieved, in particular, through the use of cryptographic algorithms, special algorithms for adding blocks to the chain, and decentralized data storage.<\/p>\n<p>When adding blocks and performing operations (transactions), private and public keys are used. They restrict blockchain users, providing them access only to their data blocks.<\/p>\n<h4>Transactions<\/h4>\n<p>\nBlockchain stores information about operations (transactions) in blocks. Old, completed transactions cannot be rolled back or changed. New transactions are stored in newly added blocks.<\/p>\n<p>Thus, the entire transaction history can be recorded in an immutable form on the blockchain. Therefore, blockchain can be used, for example, for secure storage of banking operations, copyright information, and the history of property ownership changes.<\/p>\n<p>The Ethereum blockchain contains so-called system states. As transactions are executed, the state changes from initial to current. Transactions are recorded in blocks.<\/p>\n<h4>Public and private blockchains<\/h4>\n<p>\nIt should be noted that all that has been said applies only to so-called public blockchain networks, which cannot be controlled by any individual or legal entities, government bodies, or authorities. <br \/>\nSo-called private blockchain networks are under the complete control of their creators, and everything is possible there, such as completely replacing all blocks in the chain.<\/p>\n<h4>Practical applications of blockchain<\/h4>\n<p>\nWhat can blockchain be useful for?<\/p>\n<p>In short, blockchain allows secure transactions (deals) to be conducted between parties or companies that do not trust each other. Data recorded on the blockchain (transactions, personal data, documents, certificates, contracts, invoices, etc.) cannot be forged or replaced after being recorded. Therefore, trusted distributed ledgers of various types of documents can be created based on blockchain.<\/p>\n<p>Of course, you know that cryptocurrency systems are built on blockchain technology, aiming to replace conventional paper money. Paper money is also referred to as fiat (from Fiat Money).<br \/>\nBlockchain ensures the storage and immutability of transactions recorded in blocks, which is why it can be used to create cryptocurrency systems. It contains the entire history of cryptocurrency transfers between various users (accounts), and any operation can be traced.<\/p>\n<p>Although transactions within cryptocurrency systems can be anonymous, converting cryptocurrency to fiat money usually results in the disclosure of the cryptocurrency asset owner's identity. <\/p>\n<p>So-called smart contracts, which are software running on the Ethereum network, allow the automation of deal-making processes and the monitoring of their execution. This is especially effective when payment for a transaction is made using the Ether cryptocurrency.<\/p>\n<p>The Ethereum blockchain and Ethereum smart contracts, written in the Solidity programming language, can be used, for example, in the following areas:<\/p>\n<ul>\n<li>an alternative to notarizing documents;<\/li>\n<li>maintaining a registry of real estate properties and information about transactions involving those properties;<\/li>\n<li>storing copyright information for intellectual property (books, images, musical works, etc.);<\/li>\n<li>creating independent voting systems;<\/li>\n<li>finance and banking activities;<\/li>\n<li>logistics on an international scale, tracking cargo movements;<\/li>\n<li>storing personal data as an alternative to identity verification systems;<\/li>\n<li>secure transactions in the commercial domain;<\/li>\n<li>storing medical examination results as well as a history of assigned procedures.<\/li>\n<\/ul>\n<p><\/p>\n<h4>Blockchain Issues<\/h4>\n<p>\nBut, of course, it's not so simple as it might seem! <\/p>\n<p>There are issues with verifying data before adding it to the blockchain (for example, are they fake?), problems with the security of the system and application software used to work with the blockchain, and challenges with the potential use of social engineering methods to hijack access to cryptocurrency wallets, etc.<\/p>\n<p>Again, if we're talking about a public blockchain with nodes dispersed around the world, as opposed to a private blockchain owned by an individual or organization, the level of trust here will not exceed the trust in that individual or organization.<\/p>\n<p>It is also important to consider that data recorded to the blockchain becomes accessible to everyone. In this sense, blockchain (especially public) is not suitable for storing confidential information. However, the fact that information on the blockchain cannot be altered can help prevent or investigate various types of fraudulent activities.<\/p>\n<p>Decentralized applications on Ethereum will be convenient if users pay for their use with cryptocurrency. The more people who own cryptocurrency or are willing to acquire it, the more popular DApp applications and smart contracts will become.<\/p>\n<p>Among the general blockchain issues that complicate its practical application, we can mention the limited speed of adding new blocks and the relatively high cost of transactions. However, technologies in this field are actively developing, and there is hope that technical problems will be resolved over time.<\/p>\n<p>Another issue is that smart contracts on the Ethereum blockchain operate in an isolated environment of virtual machines and do not have access to real-world data. Specifically, a smart contract program cannot read data from websites or any physical devices (sensors, contacts, etc.), nor can it output data to any external devices. We will discuss this problem and its solutions in the lesson dedicated to so-called Oracles \u2014 information intermediaries for smart contracts.<\/p>\n<p>There are also legal restrictions. In some countries, for example, using cryptocurrency as a payment method is prohibited, but it can be owned as a digital asset, similar to securities. Such assets can be bought and sold on the exchange. In any case, when creating a project that works with cryptocurrencies, it is necessary to familiarize yourself with the legislation of the country under whose jurisdiction your project falls.<\/p>\n<h3>How the blockchain chain is formed<\/h3>\n<p>\nAs we have already mentioned, blockchain is simply a chain of data blocks. The first block in this chain is created, followed by the addition of the second, and so on. It is assumed that transaction data is stored in blocks, and added to the most recent block.<\/p>\n<p>In Figure 1.1, we have illustrated a basic sequence of blocks, where the first block refers to the next one. <\/p>\n<p><img decoding=\"async\" alt=\"The book &quot;Creating Smart Contracts with Solidity for the Ethereum Blockchain: A Practical Guide&quot;\" src=\"\/wp-content\/uploads\/2019\/10\/23ca04ba2c8914334032523d01bf8b80.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>Figure 1.1. Simple sequence of blocks<\/i><\/p>\n<p>In this scenario, however, it is very easy to alter the contents of any block in the chain since the blocks contain no information to prevent modifications. Given that blockchain is intended for use by people and companies that do not trust one another, it can be concluded that such a method of data storage is unsuitable for blockchain.<\/p>\n<p>Let's work on protecting the blocks from tampering. In the first stage, we will attempt to secure each block with a checksum (Figure 1.2).<\/p>\n<p><img decoding=\"async\" alt=\"The book &quot;Creating Smart Contracts with Solidity for the Ethereum Blockchain: A Practical Guide&quot;\" src=\"\/wp-content\/uploads\/2019\/10\/141502accec14e868a9382c612cfc791.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>Figure 1.2. Adding data protection to blocks with a checksum<\/i><\/p>\n<p>Now, an attacker cannot simply change a block, as it contains the checksum of the block's data. Checking the checksum will show that the data has been altered.<\/p>\n<p>To compute the checksum, one can use one of the hashing functions, such as MD-5, SHA-1, SHA-256, etc. Hash functions calculate a certain value (for example, a string of fixed length) as a result of irreversible operations performed on the data block. The operations depend on the type of hash function. <\/p>\n<p>Even a minor change in the content of the data block will result in a different hash value. Analyzing the hash value does not allow for the reconstruction of the data block for which it was computed.<\/p>\n<p>Will such protection be sufficient? Unfortunately, no.<\/p>\n<p>In this scheme, the checksum (hash function) only protects individual blocks, not the entire chain of blocks. Knowing the algorithm for computing the hash function, an attacker could easily substitute the contents of a block. There is also nothing to prevent them from removing blocks from the chain or adding new ones.<\/p>\n<p>To protect the entire chain as a whole, one can store the hash of the previous block's data in each block along with its own data (Figure 1.3).<\/p>\n<p><img decoding=\"async\" alt=\"The book &quot;Creating Smart Contracts with Solidity for the Ethereum Blockchain: A Practical Guide&quot;\" src=\"\/wp-content\/uploads\/2019\/10\/f414ab67dbabc763c537a430e01ed065.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<i>Figure 1.3. Adding the hash of the previous block to the data block<\/i><\/p>\n<p>In this scheme, to change any block, it is necessary to recalculate the hash functions of all subsequent blocks. It seems, what\u2019s the problem?<\/p>\n<p>In real blockchains, additional artificial difficulties are created for adding new blocks \u2014 algorithms are used that require a lot of computational resources. Given that, to make changes to a block, it is necessary to recalculate not just this block but all subsequent ones, this makes it extremely difficult.<\/p>\n<p>Let\u2019s also remember that the blockchain data is stored (duplicated) on numerous network nodes, i.e., decentralized storage is used. This significantly complicates the forgery of a block, as changes need to be made on all network nodes.<\/p>\n<p>Since blocks store information about the previous block, it is possible to check the contents of all blocks in the chain.<\/p>\n<h3>Ethereum Blockchain<\/h3>\n<p>\nThe Ethereum blockchain is a platform on which distributed applications (DApps) can be created. Unlike other platforms, Ethereum allows the use of so-called smart contracts, written in the Solidity programming language.<\/p>\n<p>This platform was created in 2013 by Vitalik Buterin, the founder of Bitcoin Magazine, and launched in 2015. Everything we will study or do in our course relates specifically to the Ethereum blockchain and Solidity smart contracts.<\/p>\n<h3>Mining or how blocks are created<\/h3>\n<p>\nMining is a rather complex and resource-intensive process of adding new blocks to the blockchain, rather than 'mining cryptocurrencies'. Mining ensures the operability of the blockchain, as this process is responsible for adding transactions to the Ethereum blockchain.<\/p>\n<p>Individuals and organizations engaged in adding blocks are called miners.<br \/>\nThe software (SW) operating on the miners' nodes attempts to find a hashing parameter for the last block called Nonce, to achieve a specific value for the hash function defined by the network. The Ethash hashing algorithm used in Ethereum allows obtaining the Nonce value only through sequential trial and error. <\/p>\n<p>If a miner's node finds the correct Nonce value, it serves as what is known as proof of work (PoW, Proof-of-work). In this case, if the block is added to the Ethereum network, the miner receives a certain reward in the network's currency \u2014 Ether. At the time of writing our book, the reward is 5 Ether, but it will decrease over time.<\/p>\n<p>Thus, Ethereum miners ensure the network's operation by adding blocks and earn cryptocurrency for it. You will find a wealth of information about miners and mining online, while we will focus on creating Solidity contracts and decentralized applications (DApps) on the Ethereum network.<\/p>\n<h3>Lesson Summary<\/h3>\n<p>\nIn the first lesson, you learned about the blockchain and recognized it as a uniquely structured sequence of blocks. The contents of previously recorded blocks cannot be altered, as doing so would require recalculating all subsequent blocks across many network nodes, which demands a significant amount of resources and time.<\/p>\n<p>Blockchain can be used to preserve the results of transaction executions. Its primary purpose is to facilitate secure transactions between parties (individuals and organizations) that do not trust each other. You learned in which specific business areas and fields blockchain Ethereum and Solidity smart contracts can be used. These include the banking sector, registration of property rights, documents, etc.<\/p>\n<p>You also discovered that various issues may arise when using blockchain. These include problems with verifying information added to the blockchain, the speed of blockchain operations, the cost of transactions, the challenge of exchanging data between smart contracts and the real world, as well as potential attacks from malicious actors aimed at stealing cryptocurrency from user accounts.<\/p>\n<p>We also briefly discussed mining as the process of adding new blocks to the blockchain. Mining is necessary for transaction execution. Those who engage in mining ensure the blockchain operates effectively and earn rewards in cryptocurrency for their efforts.<\/p>\n<p><b class=\"spoiler_title\">Lesson 2. Setting Up the Working Environment in Ubuntu and Debian<\/b>Choosing the Operating System<br \/>\nInstalling the Required Utilities<br \/>\nInstalling Geth and Swarm on Ubuntu<br \/>\nInstalling Geth and Swarm on Debian<br \/>\nPreliminary Preparation<br \/>\nDownloading the Go distribution<br \/>\nSetting Environment Variables<br \/>\nChecking the Go version<br \/>\nInstalling Geth and Swarm<br \/>\nCreating a private blockchain<br \/>\n\u0413\u043e\u0442\u043e\u0432\u0438\u043c \u0444\u0430\u0439\u043b genesis.json<br \/>\nCreating a working directory<br \/>\nCreating an account<br \/>\nStarting node initialization<br \/>\nNode launch parameters<br \/>\nConnecting to our node<br \/>\nManaging mining and checking balance<br \/>\nExiting the Geth console<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 3: Setting up the working environment on Raspberry Pi 3<\/b>Preparing Raspberry Pi 3 for operation<br \/>\nInstalling Raspbian<br \/>\nInstalling updates<br \/>\nEnabling SSH access<br \/>\nSetting a static IP address<br \/>\nInstalling the Required Utilities<br \/>\nInstalling Go<br \/>\nDownloading the Go distribution<br \/>\nSetting Environment Variables<br \/>\nChecking the Go version<br \/>\nInstalling Geth and Swarm<br \/>\nCreating a private blockchain<br \/>\nChecking account and balance<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 4: Accounts and transferring funds between accounts<\/b>Viewing and adding accounts<br \/>\nViewing the list of accounts<br \/>\nAdding an account<br \/>\ngeth account command parameters<br \/>\nAccount passwords<br \/>\nCryptocurrency in Ethereum<br \/>\nCurrency units in Ethereum<br \/>\nDetermining the current balance of our accounts<br \/>\nTransferring funds from one account to another<br \/>\nMethod eth.sendTransaction<br \/>\nViewing transaction status<br \/>\nTransaction receipt<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 5: Publishing the first contract<\/b>Smart contracts in Ethereum<br \/>\nExecuting a smart contract<br \/>\nEthereum virtual machine<br \/>\nIntegrated development environment Remix Solidity IDE<br \/>\nStarting compilation<br \/>\nCalling contract functions<br \/>\nPublishing the contract in a private network<br \/>\nGetting ABI definition and contract bytecode<br \/>\nPublishing the contract<br \/>\nChecking the status of the contract publication transaction<br \/>\nCalling contract functions<br \/>\nBatch compiler solc<br \/>\nInstalling solc on Ubuntu<br \/>\nInstalling solc on Debian<br \/>\nCompiling the HelloSol contract<br \/>\nPublishing the contract<br \/>\nInstalling solc on Raspbian<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">\u0423\u0440\u043e\u043a 6. \u0421\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b \u0438 Node.js<\/b>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 Node.js<br \/>\nInstalling on Ubuntu<br \/>\nInstalling on Debian<br \/>\nInstalling and running Ganache-cli<br \/>\nInstalling Web3<br \/>\nInstalling solc<br \/>\nInstalling Node.js on Raspbian<br \/>\nScript for retrieving the list of accounts in the console<br \/>\nScript for publishing the smart contract<br \/>\nStarting and retrieving parameters<br \/>\nGetting launch parameters<br \/>\nCompiling the contract<br \/>\nUnlocking the account<br \/>\nLoading the ABI and binary code of the contract<br \/>\nEstimating the required amount of gas<br \/>\nCreating an object and launching contract publication<br \/>\nRunning the contract publication script<br \/>\nCalling smart contract functions<br \/>\nIs it possible to update the published smart contract?<br \/>\nWorking with Web3 version 1.0.x<br \/>\nRetrieving the list of accounts<br \/>\nPublishing the contract<br \/>\nCalling contract functions<br \/>\nTransferring funds from one account to another<br \/>\nTransferring funds to the contract account<br \/>\nUpdating the HelloSol smart contract<br \/>\nCreating a script to view the account balance<br \/>\n\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 getBalance \u0432 \u0441\u043a\u0440\u0438\u043f\u0442 call_contract_get_promise.js<br \/>\nFunding the smart contract account<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 7: Introduction to Truffle<\/b>Installing Truffle<br \/>\nCreating the HelloSol project<br \/>\nCreating the project directory and files<br \/>\nContracts Catalog<br \/>\nMigrations Catalog<br \/>\nTest Catalog<br \/>\n\u0424\u0430\u0439\u043b truffle-config.js<br \/>\nCompiling the HelloSol contract<br \/>\nLaunching Contract Publication<br \/>\nCalling HelloSol Contract Functions in Truffle Invitation<br \/>\n\u0412\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 HelloSol \u0438\u0437 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 JavaScript \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c Node.js<br \/>\nInstalling truffle-contract Module<br \/>\nCalling getValue and getString Contract Functions<br \/>\nCalling setValue and setString Contract Functions<br \/>\nModifying Contract and Republishing<br \/>\nWorking with Web3 version 1.0.x<br \/>\nMaking Changes to HelloSol Smart Contract<br \/>\nScripts for Calling Contract Methods<br \/>\nTesting in Truffle<br \/>\nSolidity Test<br \/>\nJavaScript Test<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 8. Solidity Data Types<\/b>Contract for Learning Data Types<br \/>\nBoolean Data Types<br \/>\nUnsigned Integers and Signed Integers<br \/>\nFixed-Point Numbers<br \/>\nAddress<br \/>\nComplex Type Variables<br \/>\nFixed-Size Arrays<br \/>\nDynamic Arrays<br \/>\nListing<br \/>\nStructures<br \/>\nMapping Dictionaries<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 9. Migration of Contracts to Private Network and Rinkeby Network<\/b>Publishing Contract from Truffle to Private Geth Network<br \/>\nPreparing Private Network Node<br \/>\nPreparing Contract for Operation<br \/>\nCompiling and Migrating Contract to Truffle Network<br \/>\nStarting Migration to Local Geth Network<br \/>\nFetching Truffle Artifacts<br \/>\nPublishing Contract from Truffle to Rinkeby Test Network<br \/>\nPreparing Geth Node for Rinkeby Operation<br \/>\nNode Synchronization<br \/>\nAdding Accounts<br \/>\nFunding Rinkeby Account with Ether<br \/>\nStarting Contract Migration to Rinkeby Network<br \/>\nViewing Contract Information in Rinkeby Network<br \/>\nTruffle Console for Rinkeby Network<br \/>\nA Simpler Way to Call Contract Functions<br \/>\n\u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Node.js<br \/>\nTransferring Funds Between Accounts in Truffle Console for Rinkeby<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 10. Decentralized Data Storage with Ethereum Swarm<\/b>How Ethereum Swarm Works<br \/>\nInstalling and Starting Swarm<br \/>\nFile and Directory Operations<br \/>\nUploading Files to Ethereum Swarm<br \/>\nReading Files from Ethereum Swarm<br \/>\nViewing Manifest of Uploaded File<br \/>\nUploading Directories with Subdirectories<br \/>\nReading File from Uploaded Directory<br \/>\nUsing Public Swarm Gateway<br \/>\n\u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a Swarm \u0438\u0437 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 Node.js<br \/>\nPerl Module Net::Ethereum::Swarm<br \/>\nInstalling Net::Ethereum::Swarm Module<br \/>\nWriting and Reading Data<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 11. Web3.py Framework for Working with Ethereum in Python<\/b>Installing Web3.py<br \/>\nUpdating and Installing Required Packages<br \/>\nInstalling easysolc Module<br \/>\nPublishing Contract with Web3.py<br \/>\nCompiling the contract<br \/>\nConnecting to Provider<br \/>\nExecuting Contract Publication<br \/>\nSaving Contract Address and ABI to File<br \/>\nRunning the contract publication script<br \/>\nCalling Contract Methods<br \/>\nReading Contract Address and ABI from JSON File<br \/>\nConnecting to Provider<br \/>\nCreating Contract Object<br \/>\nCalling Contract Methods<br \/>\nTruffle and Web3.py<br \/>\nLesson Summary<\/p>\n<p><b class=\"spoiler_title\">Lesson 12. Oracles<\/b>Can a Smart Contract Trust Data from the Outside World?<br \/>\nOracles as Information Intermediaries in Blockchain<br \/>\nData Source<br \/>\nCode to Represent Data from the Source<br \/>\nOracle for Recording Exchange Rates in Blockchain<br \/>\nContract USDRateOracle<br \/>\nUpdating Exchange Rate in Smart Contract<br \/>\nUsing Web Socket Provider<br \/>\nWaiting for RateUpdate Event<br \/>\nProcessing RateUpdate Event<br \/>\nInitiating Data Update in Smart Contract<br \/>\nLesson Summary<\/p>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/467347\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0411\u043e\u043b\u044c\u0448\u0435 \u0433\u043e\u0434\u0430 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u0434 \u043a\u043d\u0438\u0433\u043e\u0439 \u00ab\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 Solidity \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430 Ethereum. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u00bb, \u0438 \u0432\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0430, \u0430 \u043a\u043d\u0438\u0433\u0430 \u0438\u0437\u0434\u0430\u043d\u0430 \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 \u041b\u0438\u0442\u0440\u0435\u0441\u0435. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u043e\u044f \u043a\u043d\u0438\u0433\u0430 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0430\u043a\u0442\u043e\u0432 Solidity \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 DApp \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430 Ethereum. \u041e\u043d\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 12 \u0443\u0440\u043e\u043a\u043e\u0432 \u0441 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u043d\u0438\u044f\u043c\u0438. \u0412\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0438\u0445, \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":29275,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[702],"tags":[],"class_list":["post-39018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/news\/kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041a\u043d\u0438\u0433\u0430 \u00ab\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 Solidity \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430 Ethereum. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u00bb | ProHoster\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/news\/kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:27:25+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T19:27:25+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Book \"Creating Smart Contracts with Solidity for the Ethereum Blockchain: A Practical Guide\" | ProHoster","description":"","canonical_url":"https:\/\/prohoster.info\/en\/blog\/news\/kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041a\u043d\u0438\u0433\u0430 \u00ab\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043c\u0430\u0440\u0442-\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 Solidity \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430 Ethereum. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u00bb | ProHoster","og:url":"https:\/\/prohoster.info\/en\/blog\/news\/kniga-sozdanie-smart-kontraktov-solidity-dlya-blokchejna-ethereum-prakticheskoe-rukovodstvo","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:27:25+00:00","article:modified_time":"2019-10-31T19:27:25+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"39018","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-24 00:24:24","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 00:58:39","updated":"2026-01-24 00:24:24","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/39018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=39018"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/39018\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/29275"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=39018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=39018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=39018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}