<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by manasa mahesh on Medium]]></title>
        <description><![CDATA[Stories by manasa mahesh on Medium]]></description>
        <link>https://medium.com/@manasamahesh12621?source=rss-7db0e067b7af------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rDJqDSPtRPtVx5yAU52ZJw.jpeg</url>
            <title>Stories by manasa mahesh on Medium</title>
            <link>https://medium.com/@manasamahesh12621?source=rss-7db0e067b7af------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 06:52:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manasamahesh12621/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Private Ethereum Network Setup and Smart Contract Deployment with Truffle]]></title>
            <link>https://coinsbench.com/private-ethereum-network-setup-and-smart-contract-deployment-with-truffle-db979a0faec9?source=rss-7db0e067b7af------2</link>
            <guid isPermaLink="false">https://medium.com/p/db979a0faec9</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[private-network]]></category>
            <category><![CDATA[etherum]]></category>
            <category><![CDATA[etherum-blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[manasa mahesh]]></dc:creator>
            <pubDate>Thu, 15 May 2025 21:02:05 GMT</pubDate>
            <atom:updated>2025-05-19T11:13:50.396Z</atom:updated>
            <content:encoded><![CDATA[<p>The blog is about detailed guidance on how to set up a private Ethereum blockchain on your local computer for testing purposes. It encompasses the necessary steps for installation and also includes guidance on deploying a basic smart contract.</p><p>For deploying and running the Ethereum blockchain, we will use go-Ethereum, AKA geth, and for deploying the smart contract, we will use Truffle. Below is a link to download geth client based on the os: <a href="https://geth.ethereum.org/docs/getting-started/installing-geth">https://geth.ethereum.org/docs/getting-started/installing-geth</a></p><p>Below is a link to download truffle: <a href="https://trufflesuite.com/docs/truffle/how-to/install/">https://trufflesuite.com/docs/truffle/how-to/install/</a></p><p>The following points are steps that to be followed for creating etherum private network:</p><p>1. Install geth</p><p>2. Install truffle</p><p>3. Configure genesis block</p><p>4. Create nodes</p><p>5. Generate accounts for nodes</p><p>6. Initialize and start node</p><p>7. Connect to the node from command line</p><p>8. Create new account via command line</p><p>9. Transfer some Ether to new account</p><p>10. Start miner</p><p>11. Deploy a Smart Contract</p><p>12. Interact with contract using truffle</p><h3>Install Geth:</h3><p>Geth is an Ethereum client written in Go. This means running Geth turns a computer into an Ethereum node. To install it on a Linux, run the following commands:</p><p>sudo add-apt-repository -y ppa:ethereum/ethereum</p><p>sudo apt-get update</p><p>sudo apt-get install ethereum</p><p>For other versions, follow this link:</p><p><a href="https://geth.ethereum.org/docs/getting-started/installing-geth">https://geth.ethereum.org/docs/getting-started/installing-geth</a></p><h3>Install Truffle:</h3><p>Truffle is a development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM). Truffles aims to make life as a developer easier by providing built-in smart contract compilation, linking, deployment and binary management.</p><p>prerequisite:</p><ul><li>Node.js v14 — v18</li><li>Windows, Linux, or macOS</li></ul><p>In terminal, run the following command:</p><p>npm install -g truffle</p><p>To check whether or not it is installed properly, run the following:</p><p>truffle version</p><h3>Configure genesis block:</h3><p>The genesis block refers to the initial block in a blockchain network. It serves as the foundation or starting point of the entire blockchain. The genesis block is unique and distinct from subsequent blocks as it does not reference any previous block. It usually contains special parameters or data that establish the basic configuration of the blockchain, such as the timestamp of creation, the initial set of transactions, and other essential information. Each node in the network will be initialized with the same genesis block.</p><p>The following are the steps for creating the genesis block:</p><ul><li>Create a folder called “Private Network” (name could be changed based on the preference)</li><li>Create three more directories inside of the “Private Network” folder</li><li>Now, create a file in the private Network as a genesis.json, which includes the following config details in the file:</li></ul><pre>{<br>     &quot;config&quot;: {<br><br>    &quot;chainId&quot;: 8888,<br>    <br>    &quot;homesteadBlock&quot;: 0,<br>    <br>    &quot;eip150Block&quot;: 0,<br>    <br>    &quot;eip155Block&quot;: 0,<br>    <br>    &quot;eip158Block&quot;: 0,<br>    <br>    &quot;byzantiumBlock&quot;: 0,<br>    <br>    &quot;constantinopleBlock&quot;: 0<br>    <br>},<br>&quot;difficulty&quot;: &quot;200000&quot;,<br>&quot;gasLimit&quot;   : &quot;21000000&quot;,<br>&quot;gas price&quot;  : &quot;0&quot;,<br>&quot;alloc&quot;: {<br>    &quot;0x55860Df9065F504b79BF599FCf0Ce1340fD065d8&quot;: { &quot;balance&quot;: &quot;9999999999999999999999999&quot; },<br>    <br>    &quot;0x1496d986cc5194b39f82ea89A61c1b31Cf33F57e&quot; : {&quot;balance&quot;: &quot;9999999999999999999999999&quot;}<br>    <br>}    <br>}</pre><p>The given JSON represents a configuration file for a private Ethereum network. Let’s go through each key and its purpose:</p><p>“<strong>config</strong>”: This section defines various configuration parameters for the network.</p><p>“<strong>chainId</strong>”: It is a unique identifier that represents a specific blockchain network within the Ethereum ecosystem. It serves as an identifier for a particular blockchain and distinguishes it from other networks. In this case, the chainId is set to 8888. The chain ID can be assigned with any number of digit expect from 0 to 10, which are assigned to the existing network number such as the mainnet, testnets (e.g., Ropsten, Rinkeby, Kovan).</p><p>“<strong>homesteadBlock</strong>”: Indicates the block number at which the Homestead protocol rules are enabled. The value in the Ethereum configuration indicates that the specified block number or higher is considered part of the Homestead phase, and the associated protocol rules and features should be enabled.</p><p>“<strong>eip150Block</strong>”: Indicates the block number at which the EIP-150 protocol rules are enabled. EIP-150 introduces gas cost changes to address certain DOS (Denial-of-Service) attacks and mitigate the impact of spam transactions. It adjusts the gas costs for various operations to make them more efficient and discourage potential attack vectors. The EIP150Block value indicates the block number at which these gas cost changes took effect.</p><p>“<strong>eip155Block</strong>”: Indicates the block number at which the EIP-155 protocol rules are enabled. EIP-155 introduces a standardized format for transaction signatures to prevent replay attacks across different Ethereum chains. It includes a chain ID in the transaction’s signature, making each transaction unique to a specific chain and preventing the replay of transactions on different networks. The EIP155Block value represents the block number from which transactions must adhere to this new signing format.</p><p>“<strong>eip158Block</strong>”: Indicates the block number at which the EIP-158 protocol rules are enabled. EIP-158 was an update related to storage gas refunds. Prior to EIP-158, when a contract deleted data from storage, it still incurred gas costs. EIP-158 introduces gas refunds, allowing contracts to recover some gas costs when they cleared data from storage. The EIP158Block value indicates the block number from which gas refunds for storage clearing were enabled.</p><p>“<strong>byzantiumBlock</strong>”: Indicates the block number at which the Byzantium protocol rules are enabled.</p><p>“<strong>zk-SNARKs</strong>”: Byzantium includes precompiled contracts that enable the use of zk-SNARKs (zero-knowledge proofs) on the Ethereum network. This allows for more efficient and private transactions. Repricing of the SSTORE opcode: Byzantium adjusts the gas costs associated with the SSTORE opcode, which is used for storage operations. This change aims to make certain operations more cost-effective and encourage better usage of storage.</p><p>“<strong>constantinopleBlock</strong>”: Indicates the block number at which the Constantinople protocol rules are enabled. Constantinople further adjusts the gas costs for certain opcodes, making certain operations cheaper and more efficient. This aims to optimize the usage of gas on the Ethereum network. Constantinople introduces new opcodes such as CREATE2, which allows the creation of contracts at deterministic addresses based on their bytecode and initialization parameters. It also introduces EXTCODEHASH, which provides a way to retrieve the hash of a contract’s code.</p><p>“<strong>difficulty</strong>”: Mining difficulty in Ethereum refers to the level of computational effort required to mine new blocks and add them to the blockchain. It is a measure of how hard it is to find a valid block hash that satisfies the network’s consensus rules. In this case, the difficulty is set to “200000.”</p><p>“<strong>gasLimit</strong>”: Sets the maximum amount of gas that can be used in a block. The gas limit is set to “21000000.”</p><p>“<strong>gas price</strong>”: Specifies the price of gas in wei units. Here, the gas price is set to “0”, indicating that transactions can be executed without any cost.</p><p>“<strong>alloc</strong>”: This section defines the initial account balances for specific addresses.</p><p>“<strong>0x55860Df9065F504b79BF599FCf0Ce1340fD065d8</strong>”: This address is assigned a balance of “9999999999999999999999999” wei.</p><p>“<strong>0x1496d986cc5194b39f82ea89A61c1b31Cf33F57e</strong>”: This address is also assigned a balance of “9999999999999999999999999” wei.</p><h3>Create node:</h3><p>To setup a private blockchain, we will create some nodes locally in our machine.</p><p>Create 3 new directories. Each of them will represent a node in the blockchain:</p><p>mkdir node01 node02 node03</p><h3>Generate the account for node :</h3><p>Let’s create Ethereum accounts in the first node, so that later we can do some transactions for testing purposes:</p><p>geth --datadir &quot;/PATH_TO_NODE01/&quot; account new</p><p>You will be prompted for a secret password. Write down the address of the created accounts and save the password in the file as password.txt inside of the node(node01, node02, node03) folder. Now go back to the genesis file; over there, paste this account along with balance under alloc key.</p><pre>alloc:{<br>    &quot;generatedAccount1&quot;: { &quot;balance&quot;: &quot;9999999999999999999999999&quot; },<br>    <br>    &quot;generatedAccount2&quot; : {&quot;balance&quot;: &quot;9999999999999999999999999&quot;}<br>    <br> }</pre><h3>Initialize and start the nodes :</h3><p>The first step is to initialize each node with the genesis file previously created. For this, run this command for each of the nodes:</p><p>geth --datadir &quot;/PATH_TO_NODE/&quot; init /PATH_TO/genesis.json</p><p>”/PATH_TO_NODE/” will be replaced by your system path.</p><p>Then, you will start each node by running the appropriate command for each of them.</p><p>A boot node, short for bootstrap node, is a special type of node in the Ethereum network that serves as a discovery mechanism for other nodes to join the network. Its main purpose is to facilitate the initial connection and peer discovery process for new nodes.</p><p>The command “bootnode -genkey boot.key” generates a private key file for a bootnode in the Ethereum network.</p><p>bootnode -genkey boot.key</p><p>By executing this command, the bootnode will start and begin its role as a discovery mechanism for other nodes in the Ethereum network. Other nodes can connect to this bootnode using the provided address and port, obtain a list of known peers, and join the Ethereum network.</p><p>bootnode -nodekey boot.key -addr :30306</p><p>output :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fRbmCKdNRbq-fNYR" /></figure><p>The term “enode address” refers to the Ethereum Node Identifier. It is a unique identifier assigned to each node in the Ethereum network. An enode address consists of several components that provide information about the node’s network location and capabilities.</p><p>The enode address has the following format:</p><p>enode://&lt;node-id&gt;@&lt;ip-address&gt;:&lt;port&gt;?discport=&lt;discovery-port&gt;</p><p>Let’s break down the components of an enode address:</p><p><strong>node-id:</strong> This is a unique identifier for the node, typically represented as a combination of letters and numbers. It serves as a globally unique identifier for the node in the Ethereum network.</p><p><strong>ip-address:</strong> This IP address of the node. It specifies the network location where the node can be reached.</p><p><strong>port:</strong> This port number on which the node is listening for incoming connections. It is used to establish network communication with the node.</p><p><strong>discport=discovery-port:</strong> This component specifies the discovery port, which is used for the node’s peer discovery mechanism. It allows other nodes to find and connect to the node.</p><p>To bring up the private network using geth, run the command below:</p><blockquote>geth --datadir node01 --port 30306 --bootnodes enode://7ace3d114e928ab51cf399286eb2eceb3eb286f22c1b418053def3203e2368586320b20fd07401fe49b48353441e5c403b00e83cbd78da21639eae9f4a4405aa@127.0.0.1:0?discport=30307 --unlock 0x55860Df9065F504b79BF599FCf0Ce1340fD065d8 --password password.txt --authrpc.port 8551 --authrpc.addr 127.0.0.1 --authrpc.vhosts * --rpc.enabledeprecatedpersonal --http --http.api &quot;web3,eth,personal,net,miner&quot; --http.corsdomain &quot;*&quot; --http.vhosts &quot;*&quot; --http.port 8552 --allow-insecure-unlock --miner.etherbase &quot;0x55860Df9065F504b79BF599FCf0Ce1340fD065d8&quot; --rpc.allow-unprotected-txs --mine</blockquote><p>This is a command-line instruction for running a Geth node with various configurations and options. Let’s break down the different parts of the command:</p><p>--geth: The command to start the Geth Ethereum client.</p><p>--datadir node01: Specifies the data directory for the Geth node, where the blockchain data and other node-related files will be stored.</p><p>--port 30306: Sets the port number on which the node will listen for incoming connections from other nodes.</p><p>--bootnodes: Specifies the list of bootstrap nodes that the current node should connect to for peer discovery and network synchronization. In this case, it provides an enode URL for a bootnode with authentication credentials.</p><p>--unlock: Unlocks the specified Ethereum account, allowing it to sign transactions. Here, 0x55860Df9065F504b79BF599FCf0Ce1340fD065d8 is the address of the account to be unlocked. The account name 0x55860Df9065F504b79BF599FCf0Ce1340fD065d8 should be replaced with your system generated account name, which is generated for your nodes.</p><p>--password password.txt: Specifies the path to a file containing the password to unlock the account.</p><p>--authrpc.port, --authrpc.addr, --authrpc.vhosts: Configures the RPC (Remote Procedure Call) server to listen on the specified port and address with virtual host support.</p><p>--rpc.enabledeprecatedpersonal: Enables the deprecated personal API for interacting with Ethereum accounts and managing transactions.</p><p>--http: Enables the HTTP-RPC server, allowing remote interaction with the Geth node via HTTP.</p><p>--http.api: Specifies the APIs to enable for the HTTP-RPC server. Here, &quot;web3,eth,personal,net,miner&quot; enables the Web3, Ethereum, Personal, Network, and Miner APIs.</p><p>--http.corsdomain, --http.vhosts, --http.port: Configures CORS (Cross-Origin Resource Sharing) domain, virtual host support, and the port number for the HTTP-RPC server.</p><p>--allow-insecure-unlock: Allows insecure unlocking of the account by accepting plaintext passwords over HTTP.</p><p>--miner.etherbase: Sets the Ethereum address that will receive mining rewards when mining is enabled. The account name 0x55860Df9065F504b79BF599FCf0Ce1340fD065d8 should be replaced with your system generated account name, which is generated for your nodes.</p><p>--rpc.allow-unprotected-txs: Allows unprotected (non-encrypted) transactions over the RPC interface.</p><p>--mine: Enables mining on the node, which means the node will participate in the process of validating and adding new blocks to the blockchain.</p><p>Overall, this command starts a Geth node with specified configurations, connects to boot nodes, unlocks an Ethereum account, enable various APIs and services, and allows mining and transaction processing. It provides a way to interact with the Ethereum network via RPC and perform mining operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nfZhwlbOuYqDkdhr" /></figure><h3>Connect to the Node via command line :</h3><p>In order to interact with the nodes you need to open a terminal and use geth to attach to it.</p><p>Run the following command for each of the nodes by opening a separate terminal and use the correct port number for each node.</p><p>geth attach <a href="http://127.0.0.1:8552/">http://127.0.0.1:8552</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/0*Agjo868eu_AfmkP9" /></figure><h3>Create new account through CLI:</h3><p>Create a new account through command line interface using following command:</p><p>personal.newAccount()</p><p>Transfer some ether to new account:</p><p>eth.accounts</p><p>check the balance of the account:</p><p>eth.getBalance(eth.accounts[0])</p><p>Now unlock the account in order to start a transaction using this account:</p><p>personal.unlockAccount(eth.accounts[0])</p><p>send some Ether to verify whether the connection is established successfully:</p><p>eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:1000})</p><p>Now you will get the prompt for entering the password, which was generated at the time of account creation.</p><p>The next step is to start a miner so that this transaction is actually processed and persisted into the blockchain.</p><h3>Start a Miner</h3><p>The first thing to do is to set an account to receive the mining awards. This is called the etherbase account.</p><p>Go to the console and run:</p><p>miner.setEtherbase(eth.accounts[0])</p><p>and then run the command:</p><p>miner.start()</p><p>You should see null as a response; once this command got executed successfully.</p><p>Currently, in the other console where node is running you should see the progress of the mining that you just started.</p><p>You can now verify the balance of the account and check that the transfer was done properly.</p><p>eth.getBalance(eth.accounts[1])</p><h3>Deploy a Smart Contract</h3><p>In this section, we create and deploy a simple smart contract into our network. For deployment we will use the development framework of Etherum called “Truffle”.</p><p>To install the Truffle library:</p><p>npm install -g truffle</p><p>Next we will initialize a new Truffle project by running this command in a newly created folder:</p><p>truffle init</p><p>After the creation of initial files and directories, you’ll need to update the truffle-config.js file to ensure Truffle can establish a connection with your network. Modify the file with the following content, making sure to replace the port number with the one corresponding to your first node’s running port. Additionally, in the address field provide the complete address of the first account created in that node.</p><pre>networks: {<br>     private: {<br>     host: &quot;127.0.0.1&quot;,<br>     port: 8552,<br>     network_id: &quot;*&quot;,<br>     gas: &quot;800000&quot;, // (default: 6721975)<br>     from: &quot;0x55860Df9065F504b79BF599FCf0Ce1340fD065d8&quot;, // (give the account number which is generated as part of node creation)<br>    chainId: 8888,<br>   },<br>   }</pre><p>Next, open the contracts folder and create a new file called “calculator.sol.”</p><p>For sample, you can use below code, which is a simple contract written in the Solidity language.</p><pre>pragma solidity ^0.8.0;<br>contract Calculator {<br>function add(uint256 a, uint256 b) public pure returns (uint256) {<br>return a + b;<br>}<br>function subtract(uint256 a, uint256 b) public pure returns (uint256) {<br>return a - b;<br>}<br>function multiply(uint256 a, uint256 b) public pure returns (uint256) { <br>return a * b; <br>}<br>function divide(uint256 a, uint256 b) public pure returns (uint256) { <br>require(b != 0, &quot;Division by zero&quot;); return a / b;<br>}<br>function square(uint256 a) public pure returns (uint256) { <br>return a²;<br>} <br>}</pre><p>The next step is to update the migrations file so that Truffle knows that this file need to be compile and migrate the contract that we just created.</p><p>Open the “1_deploy_contract.js” file located in the migrations folder and modify its content to match the following:</p><blockquote>const Calculator = artifacts.require(&quot;Calculator&quot;);</blockquote><blockquote>module.exports = function (deployer) {</blockquote><blockquote>deployer.deploy(Calculator);</blockquote><blockquote>};</blockquote><p>Now, we can utilize Truffle to compile our contract and deploy it to our newly created private network.</p><p>It is important to note that Truffle will also provide a support to compile and deploy its migrations contract.</p><p>The migrations contract serves the purpose of tracking the deployed versions of our contracts and ensuring they remain up-to-date.</p><p>Go to the folder “contracts” and run the following command:</p><p>truffle compile</p><p>Next we need to unlock the account in the node, as we are going to deploy the contract using that account.</p><p>Go to the terminal that is attached to the respective node and run this below line:</p><p>personal.unlockAccount(eth.accounts[0])</p><p>Finally, go back to the contracts folder and run the below to deploy the contract:</p><p>truffle migrate</p><p>The contract should now be deployed in your network in a new address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/0*twNY9TY_XAuDVNBe" /></figure><h3>Interact with contract using truffle</h3><p>To establish the connection with deployed contracts, run:</p><p>truffle console</p><p>you can now interact with contract instance. It’s functions and state variables. You can call contract functions using the instance&#39;s method calls. For example:</p><p>let variableName = await myContractInstance.myFunction(); // Replace &#39;myFunction&#39; with the actual function name</p><p>console.log(variableName); // Output the result or perform further actions</p><p>Here, sample test cases to test the deployed contract,</p><p>let MyContract = artifacts.require(&#39;Calculator&#39;);</p><p>let result = await MyContract.deployed();</p><p>let addResults = await result.add(4,3);</p><p>console.log(addResults);</p><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*8lVhIME8NdxhEFwiF1P0KA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db979a0faec9" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/private-ethereum-network-setup-and-smart-contract-deployment-with-truffle-db979a0faec9">Private Ethereum Network Setup and Smart Contract Deployment with Truffle</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dapp-example — How to create contract in etherum using calculator example.]]></title>
            <link>https://coinsbench.com/dapp-example-how-to-create-contract-in-etherum-using-calculator-example-abc676246e33?source=rss-7db0e067b7af------2</link>
            <guid isPermaLink="false">https://medium.com/p/abc676246e33</guid>
            <dc:creator><![CDATA[manasa mahesh]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 06:00:59 GMT</pubDate>
            <atom:updated>2025-05-19T11:13:35.562Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dapp — How to create contract in Etherum using Solidity(calculator example).</h3><p>This blog provides the step-by-step process for creating and deploying a smart contract using Remix and the Truffle framework. It walks you through setting up your contract in Remix, then deploying it to a local blockchain environment called Ganache, which is a developer blockchain environment for developing and testing. By following this instruction, you will learn how to seamlessly deploy and run your contract in Ganache using migrates, a tool specifically designed for testing and development purposes.</p><p>Following are the steps to create and deploy a contract into the Ganache.</p><ul><li>Install GANACHE from <a href="https://trufflesuite.com/ganache/">here</a>.</li><li>Install TRUFFLE from <a href="https://trufflesuite.com/docs/truffle/how-to/install/">here</a>.</li><li>In <a href="https://remix.ethereum.org/">REMIX</a> , Create a folder in default workspace.</li><li>Create the contract inside of the folder using the extension .sol(eg: calculator.sol, hello.sol).</li><li>Compile the code by choosing an appropriate compiler version in the “solidity compiler” section. Once code is compiled successfully, it generates an ABI byte code of the contract.</li><li>In the “deploy and run transaction” section, select environment as dev- ganache.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KLDekF9WrXDAmp2Y" /></figure><ul><li>Select your etherum account number from the drop down box in the “account” section for deducting gas value for deploying contract.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*T4uPOJtoUw0r6XJa" /></figure><ul><li>Now, click the button “Deploy” for deploying the contract in to Ganache.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fv1Ko6d0tmHxTRlF" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CPAv8wYzheVwT5MW" /></figure><ul><li>Once contract is deployed, we can see the deployed message regarding the contract in the remix console.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SSA9hl3lYGyl_hbp" /></figure><ul><li>Test the contract by giving sample data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RkVlglI5SHVt3yH4" /></figure><p><strong>In Truffle :</strong></p><ul><li>Install <strong>VS Code.</strong></li><li>Currently, I have choosed the VScode as a editor, which provides the development environment for writing and managing smart contracts.</li><li>Install Truffle framework globally using npm in terminal as following:</li></ul><blockquote>npm install -g truffle</blockquote><p>Now, you will see the sample folder would have created.</p><ul><li>Folder structure should be in the below format:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/0*_kJjLCDInAmYoqLr" /></figure><ul><li>Now, in the terminal run command as Truffle compile</li><li>For deployment, migrate scripts need to be added in the “migrations” folder which is a feature provided by Truffle as part of their framework.</li><li>Create file inside of the “migrations” folder , where filename should be prefixed with number_deploy_filename.js (eg: 1_deploy_contract.js).</li><li>Now add local network details in the truffle-config.js for connecting with Ganache blockchain.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/0*u2oIByTkSPRtUCTk" /></figure><ul><li>Run command Truffle Migrate --network development</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GOVlE6240-AEl26t" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N3R04XnorGA9HK77" /></figure><ul><li>Run command Truffle console to interact with deployed contract.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pkTxrxC85X1aKoYE" /></figure><ul><li>For testing, where deployed contracts are working as expected, test cases can be added in to the truffle “test” folder using Mocha and Chai.</li><li>Run command Truffle test for running the test cases.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/0*2Y0oWrucAEwZCCBE" /></figure><p>Now calculator application is ready to use !!!.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abc676246e33" width="1" height="1" alt=""><hr><p><a href="https://coinsbench.com/dapp-example-how-to-create-contract-in-etherum-using-calculator-example-abc676246e33">Dapp-example — How to create contract in etherum using calculator example.</a> was originally published in <a href="https://coinsbench.com/">CoinsBench</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy PENN Stack Web App in Azure Linux Virtual Machine]]></title>
            <link>https://medium.com/geekculture/deploy-penn-web-app-in-azure-linux-virtual-machine-bd790b1bc487?source=rss-7db0e067b7af------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd790b1bc487</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[azure-virtual-machines]]></category>
            <category><![CDATA[azure-pipelines]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[penn-stack]]></category>
            <dc:creator><![CDATA[manasa mahesh]]></dc:creator>
            <pubDate>Mon, 05 Apr 2021 20:08:20 GMT</pubDate>
            <atom:updated>2021-04-12T23:05:19.119Z</atom:updated>
            <content:encoded><![CDATA[<h4>PENN is acronym for its component parts: Postgres , Express, Next js and Nodejs .</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fr0GBclPfOhRzOwctro1BA.jpeg" /></figure><p>PENN is consists of following technologies:</p><p><strong>Postgres : </strong>it is object relational database which provide feature like creating function, triggers, inheritance and function overloading .</p><p><strong>Express</strong>: A backend web application Framework for Nodejs.</p><p><strong>Next JS : </strong>A frontend java script library for building graphical user interface, which is build on top of the React JS.</p><p><strong>Nodejs:</strong> A java script runtime environment for executing java script source code .</p><p><strong>initial-Setup:</strong></p><p>find complete code for the<a href="https://github.com/Manasamahesh/PERN"><strong> PENN stack</strong></a> which is sample project of PENN stack.</p><p>install few requirement before starting with PENN stack. check whether node installed or not</p><blockquote>$ node -v</blockquote><p>this will show version of the node have been installed in our system. If it is not present then install<a href="https://nodejs.org/en/download/"> node js</a> .</p><p>now, we will create basic next js-project by using create-next-app, the npx or yarn command can be used for creating it.</p><blockquote>$ npx create-next-app project name or yarn create-next-app project name</blockquote><p>above command creates folder with given project name template of basic nextjs and all dependencies installed.</p><p>change into this directory.</p><blockquote>$ cd project name</blockquote><p>start development web server by running the following command:</p><blockquote>$ npm start</blockquote><p><strong>Backend Folder:</strong></p><p>create new folder backend and change into backend folder:</p><blockquote>$ mkdir backend</blockquote><blockquote>$ cd backend</blockquote><p>we create package.json and install dependencies.</p><blockquote>$ npm init -y</blockquote><blockquote>$ npm install express cors pg</blockquote><blockquote>$ npm install -g nodemon</blockquote><p><a href="https://portswigger.net/web-security/cors">CORS</a> allows resource to be accessed from remote hosts.pg makes Nodejs to interact with postgres database. nodemon tool that helps Nodejs based application by restarting server whenever changes occurred in node file.</p><p>In the backend directory create index.js that act as server, will have CORS, express ,endpoints and create port 5000 to listen.</p><p>Now we can connect to our database by adding below line in index.js</p><blockquote>const pool = require (“pg”).pool;</blockquote><p><strong>Configure Database connection:</strong></p><blockquote>const pool = new pool({ user:”postgres”, password:”WE1&quot;, host:”localhost”, port: 5432, database:”pernStack” });</blockquote><p><strong>Create Basic Database:</strong></p><p>create Database PERN Stack to persist data received from user interface.</p><blockquote>create Database pernStack;</blockquote><blockquote>create Table pernTable( pern_id SERIAL primary key description VARCHAR(255));</blockquote><p><strong>Frontend:</strong></p><p>Next js provide solution for <a href="https://nextjs.org/learn/basics/create-nextjs-app">drawbacks</a> of React js .Next js page is React component exported from a .js, .jsx, .ts, or .tsx . file name is mapped to the route path of the pages in the directory. for Example, if we create page/intro.js that exports a React component like below is available at endpoint /intro.</p><pre>function intro() {<br>  return &lt;div&gt;Hello World&lt;/div&gt;<br>}<br><br>export default intro</pre><p>React component show details fetched from database and also shows a user interface from where details to take in and persisted into database . React will re-render when changes occurred.</p><pre>$ npm start</pre><p><strong>Deploy into Azure Linux Machine through Azure pipeline:</strong></p><p>Azure Devops Provides complete lifecycle of project — begins from planning to Testing.</p><p>Azure Devops consists of following services for project:</p><ol><li><strong>Azure Board-</strong> it is a service for tracking task in the projects and also provide support for scrum and Kanban board.</li><li><strong>Azure Repos -</strong>it is a version control service provided by Azure</li><li><strong>Azure pipeline-</strong> it is pipeline service for build and deploying project</li><li><strong>Azure Test plan-</strong> it provides detailed plan for testing deployed projects</li><li><strong>Artifacts-</strong> it stores package for pipeline deployment.</li></ol><p><strong>Create Linux Web app:</strong></p><ol><li>Create resources from azure dashboard.</li><li>choose web app and select Linux server choose publish as code.</li><li>select runtime as node.</li><li>operating system as Linux ,review and create it.</li><li>Now configure<a href="https://www.postgresqltutorial.com/install-postgresql-linux/"> postgres database</a> inside of Linux server.</li><li>create database and create table .</li></ol><blockquote><em>create Database pernStack;</em></blockquote><blockquote><em>create Table pernTable( pern_id SERIAL primary key description VARCHAR(255));</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*feF8Yc0jc3inJK1pAMgD3Q.png" /></figure><p><strong>initial setup for Azure Devops:</strong></p><ol><li>Login into <a href="https://azure.microsoft.com/en-in/services/devops/">Azure Devops </a>.</li><li>create new Project .</li></ol><p>choose Azure pipeline and create New pipeline, select GitHub .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AS3KUpRJc8jAtnIRqNiI1Q.png" /><figcaption>repository selection</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S82i6j01GQtW9XZ1CJgCNQ.png" /><figcaption>configure pipeline type</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-eS_csj1pg0w3Mxy0KRdA.png" /><figcaption>review pipeline save and run</figcaption></figure><p><strong>pipeline for Backend deployment:</strong></p><ol><li>Provide authorization for Azure pipeline to access repository .</li><li>Now choose repository have been listed from GitHub.</li><li>configure your pipeline to build Node JS App and deploy it into Azure Linux web app.</li><li>choose subscription details and login into account.</li><li>choose Linux server have present in your account, if Linux server is not created then follow steps to create server.</li></ol><blockquote>Go to dashboard and create resource choose web app then provide details Linux server with node ,click Review and create.</blockquote><p>9. Now in the Review stage you will find yaml code for azure pipeline configuration, here we can add or remove line for inline script to be executed in Linux server.</p><p>10.click save and run, it will commit yaml into GitHub repository.</p><p>11. Now build starts for backend and got deployed successfully.</p><p><strong>pipeline for Frontend deployment:</strong></p><ol><li>Provide authorization for Azure pipeline to access repository .</li><li>Now choose repository have been listed from GitHub.</li><li>configure your pipeline to build React JS App and deploy it into Azure Linux web app.</li><li>choose subscription details and login into account.</li><li>choose Linux server in which backend service have been deployed .</li><li>Now in the Review stage you will find yaml code for azure pipeline configuration, here we can add or remove line for inline script to be executed in Linux server.</li><li>click save and run, it will commit yaml into GitHub repository.</li><li>Now build starts for backend and got deployed successfully.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*snm8S9-tPtW7atmFxh7bIg.png" /><figcaption>pipeline build</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgg7sZarCBMivzXZE0Zpeg.png" /><figcaption>pipeline deployment</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd790b1bc487" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/deploy-penn-web-app-in-azure-linux-virtual-machine-bd790b1bc487">Deploy PENN Stack Web App in Azure Linux Virtual Machine</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>