Creation and Deployment of Smart Contracts on Ethereum Blockchain. Dr. Hidaia Mahmood Alassouli

Читать онлайн.
Название Creation and Deployment of Smart Contracts on Ethereum Blockchain
Автор произведения Dr. Hidaia Mahmood Alassouli
Жанр Сделай Сам
Серия
Издательство Сделай Сам
Год выпуска 0
isbn 9783969448571



Скачать книгу

command

      choco install git –y

       Or download the installer from "https://gitforwindows.org/" link.

       Install Visual Studio Code along with solidity extension. To install either run below command

      . choco install VisualStudioCode –y

       Or download the installer from "https://www.visualstudio.com/downloads/" link

       Install Python on Windows. To install either run below command

      choco install python –y

       Or download the installer from "https://www.python.org/downloads/" link.

       Open the visual studio consol. Go to extensions page. Install the solidity extension

       Install Python on Windows. To install either run below command

      choco install python –y

       Install Ganache on Windows. Download the installer from below link. http://truffleframework.com/ganache/

       Or install it from command line

      npm install –g ganache -cli

       What is ganache.When you develop application, that application will be held in application server. In case of Ethereum, the Ethereum blockchain will hold the smart contract. The blockchain is acting as application server. Ganache is simulation blockchain that runs locally in the system and simulate the Ethereum blockchin for you. It comes as GUI or command line.

       When you run ganache, you will see this image. You see many ether addresses. Each ether address has some ethereum on it.

Image

       Remix is IDE used to build smart contract. Remix web based IDE https://remix.ethereum.org

       Install IDE from git or npm using below command npm

      install remix-ide -g remix-ide git clone https://github.com/ethereum/remix-ide...

      cd remix-ide

      npm install

      npm run setupremix

      npm start

      5. How to compile and deploy smart contract on JavaScriptVM

       URL to open Remix IDE https://remix.ethereum.org

       When we compile the solidity code, we get byte code that we can deploy in Ethereum blockchain.

       Start new contract student.sol

       Below is smart contract code

      pragma solidity ^0.4.18;

      contract student {

       string name;

       uint age;

       function setStudentDetails(string _name, uint _age) public{

       name=_name;

       age=_age;

      }

       function getStudentDetails() public view returns(string, uint){

       return (name, age);

       }

      }

       We must deploy the smart contract on Blockchain. There are different blockchains available.Among them are: main net block chain and test net blockchains. Or we can deploy the smart conract on our self blockchain environment. We will use first to deploy smart contract on the inbuilt blockchain inside the Remix IDE which is Java Script VM.

Image

       To deploy the smart contract on Java Script VM blockchain, we need an account. We get bay default in Remix 5 accounts. But if we deploy the smart contract in Ethereum blockchain, we must create an account there.

       We choose any account and deploy the smart contract on Java Script VM, click deploy. When the smart contract deployed, it will be deployed on some address. The address assigned by blockchain to that smart contract. So we can always refer to smart contract by that address only.

       We need ethereum to deploy the smart contract in the main net Ethereum blockchain. Because the miner will mine your transection and when itsis confirmed, it must get some fees.

       When you assign values to variables, you change the state of the variables, that means you make changes in block chain, and you must pay gas for that. Someone will mine the transaction and then it will be successful. Get function output the values of variables and does not change state of block chin. So it does not require mining and no fees required.

       Debugger allows you to debug the smart contract

      Конец ознакомительного фрагмента.

      Текст предоставлен ООО «ЛитРес».

      Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.

      Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.

/9j/4AAQSkZJRgABAQEBLAEsAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdC IFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAA AADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlk ZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAA AChnVFJDAAABoAAA