<?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 Sameep singhania on Medium]]></title>
        <description><![CDATA[Stories by Sameep singhania on Medium]]></description>
        <link>https://medium.com/@sameepsi?source=rss-737d685e908d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*r8iyqn7UiX2BzOj7rXkwIA.jpeg</url>
            <title>Stories by Sameep singhania on Medium</title>
            <link>https://medium.com/@sameepsi?source=rss-737d685e908d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 03:05:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sameepsi/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[Gasless/Meta transactions on Matic using Biconomy]]></title>
            <link>https://medium.com/ginete-technologies/gasless-meta-transactions-on-matic-using-biconomy-bfae7ae8e743?source=rss-737d685e908d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfae7ae8e743</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[biconomy]]></category>
            <category><![CDATA[meta-transactions]]></category>
            <category><![CDATA[matic-network]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Sameep singhania]]></dc:creator>
            <pubDate>Sun, 14 Jun 2020 18:41:19 GMT</pubDate>
            <atom:updated>2020-06-14T18:45:11.431Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Matic</strong> Network is a blockchain scalability platform that provides secure, scalable, and instant transactions powered by PoS side chains and an adapted version of Plasma. You can learn more about Matic <a href="https://matic.network/">here</a></p><p><strong>Biconomy</strong> is a relayer infrastructure network and transaction platform enabling you to build applications easily and reduce the friction between your applications built on the blockchain and your end-users. You can learn more about biconomy <a href="https://biconomy.io/">here</a></p><p>In this article, we will learn how to enable <a href="https://medium.com/@austin_48503/ethereum-meta-transactions-90ccf0859e84">gasless/meta</a> transactions in a DApp deployed on Matic using Biconomy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*_VvJXUzwrZ6rDlMKCPWJzw.png" /><figcaption>Ginete Technologies Private Limited</figcaption></figure><p>In this article, we will create a simple <strong>Token Transfer DApp</strong>.</p><p>This post is divided into the following 5sections-:</p><ol><li>Setting up the development environment</li><li>Developing the Smart Contract</li><li>Deploying the smart contract to Matic</li><li>Registering contracts on Biconomy</li><li>Developing the front-end with gasless transactions</li></ol><h3>1. Setting up the development environment</h3><p>The setup instructions are tested on Ubuntu 16.04 LTS. But they should work fine for macOS as well.</p><p>Open a new terminal.</p><pre>&gt; sudo apt-get update<br>&gt; curl -sL <a href="https://deb.nodesource.com/setup_8.x">https://deb.nodesource.com/setup_8.x</a> -o nodesource_setup.sh<br>&gt; sudo bash nodesource_setup.sh<br>&gt; sudo apt-get install nodejs<br>&gt; npm install -g truffle</pre><p>This will install nodejs and <a href="https://www.trufflesuite.com/">truffle</a>.</p><p>Open a new terminal and perform these steps</p><pre>&gt; cd ~<br>&gt; mkdir tutorial<br>&gt; cd tutorial<br>&gt; npx create-react-app meta-tx<br>&gt; cd meta-tx<br>&gt; truffle init<br>&gt; npm i --save web3 openzeppelin-solidity@2.5.1 truffle-hdwallet-provider dotenv @biconomy/mexa eth-sig-util</pre><p>The above commands will do the following-:</p><ol><li>Create a new directory <strong>tutorial/meta-tx</strong>. From now we will call this directory our working directory</li><li>Initialize the create-react-app project inside our working directory</li><li>Initialize truffle project inside our working directory</li><li>Install <strong>web3.js</strong>,<strong> openzeppelin-solidity</strong>,<strong> dotenv</strong>,<strong> eth-sig-util</strong>, <strong>@biconomy/mexa</strong> and <strong>truffle-hdwallet-provider </strong>node packages</li></ol><p>Your working directory should have the following directory structure after executing above commands</p><pre>&gt; meta-tx<br>  &gt; contracts<br>  &gt; migrations<br>  &gt; public<br>  &gt; src<br>  &gt; test<br>  &gt; package.json<br>  &gt; truffle-config.js</pre><h3>2. Developing the Smart Contract</h3><p>We will be using <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md">EIP712</a> standard to enable gasless/meta transactions in our DApp.</p><p>Now create <strong>EIP712Base.sol</strong> file in the <strong>contracts</strong> folder in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88afcf7f9c76b429c3d4a95f58ae4dcd/href">https://medium.com/media/88afcf7f9c76b429c3d4a95f58ae4dcd/href</a></iframe><p><strong>EIP712Base </strong>contract contains base functionalities to support <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md">EIP712</a></p><p>Now create <strong>EIP712MetaTransaction.sol</strong> in the <strong>contracts</strong> folder in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d226fbfc955b9b351f1e07d54a73d340/href">https://medium.com/media/d226fbfc955b9b351f1e07d54a73d340/href</a></iframe><p><strong>EIP712MetaTransaction </strong>contract contains functionality to support meta transactions. It does the following operations-:</p><ol><li>Calculating meta transaction hash</li><li>User signature verification as per <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md">EIP712</a></li><li>Executing meta transaction</li></ol><p>Now create <strong>GineteToken.sol</strong> in the <strong>contracts</strong> folder in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0705e653c4305c10f8c83e21c3ef0527/href">https://medium.com/media/0705e653c4305c10f8c83e21c3ef0527/href</a></iframe><p><strong>GineteToken</strong> is a simple ERC20 token that inherits <a href="https://openzeppelin.com/contracts/">openzeppelin’s</a> ERC20, ERC20Detailed and EIP712MetaTransaction created in the previous step.</p><h3>3. Deploying the smart contract to the Matic testnet</h3><p>To deploy <strong>GineteToken</strong> smart contract we will have to follow these steps-:</p><ol><li>Compile the contract</li><li>Add environment variable</li><li>Update truffle’s migration file</li><li>Create migration file for GineteToken</li><li>Deploy the contract on the matic testnet using truffle migration</li></ol><p>Now let’s compile our contract. Follow the commands below to compile GineteToken contract.</p><p>Open a new terminal and perform these steps</p><pre>&gt; cd ~/tutorials/meta-tx<br>&gt; truffle compile</pre><p>The above command will compile your <strong>GineteToken</strong> contract and the generated artifacts will be saved inside <strong>build/contracts</strong> folder within your working directory.</p><p>Now let’s add required environment variables in our project.</p><p>Create <strong>.env</strong> file in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d3fcdd81afaaad495ecb73de8ed314f/href">https://medium.com/media/3d3fcdd81afaaad495ecb73de8ed314f/href</a></iframe><p>The content of the .env file is the <strong>private key</strong> associated with the account(0x46CFAE95AA3172B1E30E0F7103A09A1DabC60941) which will be used to deploy the <strong>GineteToken</strong> contract on matic testnet</p><p><strong>NOTE: Please do not use the above mentioned private key in production.</strong></p><p>Now let’s update our truffle migration file.</p><p>Please replace the contents of the <strong>truffle-config.js</strong> file in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9c5c81cf57e87a4dd2a08f8dc136f24/href">https://medium.com/media/a9c5c81cf57e87a4dd2a08f8dc136f24/href</a></iframe><p>Now let’s create the migration file for the GineteToken.</p><p>Please create <strong>2_GineteToken_migration.js</strong> inside the <strong>migrations</strong> folder in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39a0657c16e791138fdde5ad8ad2ef47/href">https://medium.com/media/39a0657c16e791138fdde5ad8ad2ef47/href</a></iframe><p>Now let’s deploy our compiled contract on the blockchain, in our case matic testnet. Before running the next steps please ensure that you have completed the above steps successfully.</p><p>Open a new terminal and perform the following steps</p><pre>&gt; cd ~/tutorials/meta-tx<br>&gt; truffle migrate --network matic --reset</pre><p>The above commands will deploy GineteToken on the matic testnet using truffle’s migration.</p><p>The output of the above command should look similar to this image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*_h0_xeC0Kt-FCwWiwrA0Eg.png" /></figure><p>The output should contain the address of the <strong>GineteToken</strong> deployed on matic testnet. In above image the address of the GineteToken is <strong>0xc9fa015042CE672ffAC9761206504967A128fb59.</strong></p><p>Please keep this address safe somewhere. We will be needing this address in upcoming steps.</p><h3>4. Registering contracts on Biconomy</h3><p>To register contracts on thebiconomy we will have to follow these steps-:</p><ol><li>Create an account on the biconomy</li><li>Register our DApp on the biconomy dashboard</li><li>Add <strong>GineteToken</strong> Contract in your DApp</li><li>Add <strong>executeMetaTransaction</strong> API for the GineteToken contract</li></ol><p>Go to <a href="https://dashboard.biconomy.io/signup">biconomy</a> dashboard and create your account.</p><p>Now let’s register our DApp on biconomy. Goto biconomy dashboard and click on <strong>Register</strong> in <strong>Your Dapps</strong> section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*BWtI2dzArTOVcJaw3b6BHw.png" /></figure><p>Enter the following information while registering your dapp-:</p><ol><li>Enter Dapp name</li><li>Select <strong>Matic Testnet 3</strong> in Network dropdown</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*hjaXvjB_KA2urCIuHDsx8A.png" /></figure><p>Click on <strong>Create</strong></p><p>The above step will register a <strong>GineteToken</strong> dapp in your biconomy dashboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*sPom2DwVYrHyhhYXylyRgA.png" /></figure><p>Now let’s add our GineteToken contract in our recently registered dapp.</p><p><strong>Note- Please copy API Key from the newly created DApp. We will be needing in upcoming steps.</strong></p><p>Click on the <strong>View Dapp</strong> button. It should open a screen like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTPRq8ATu69tKq0ZqYbcrg.png" /></figure><p>Click on <strong>Add Contract</strong> button in <strong>Smart Contracts</strong> section. Please enter the following information-:</p><ol><li>Name- GineteToken</li><li>Address- Address of the GineteToken deployed in <strong>Step</strong> <strong>3</strong></li><li>ABI- Copy and paste this <a href="https://gist.github.com/sameepsi/7d1c42921d7d4e5977d98d949c293ffb">abi</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*dha0e1DxgAbHEYiaol1UoA.png" /></figure><p>Click on <strong>Add</strong>.</p><p>Now let’s add <strong>executeMetaTransaction</strong> API for our GineteToken contract.</p><p>Click on <strong>Manage APIs</strong> button in <strong>DAPP APIs</strong> section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYJ7jT_b7q-6-6zzy23CdQ.png" /></figure><p>Now click on <strong>New API</strong> button. Please enter the following information-:</p><ol><li>Smart Contract- <strong>GineteToken</strong></li><li>Method- <strong>ExecuteMetaTransaction</strong></li><li>Name- <strong>executeMetaTransaction</strong></li><li>Enable Native meta-tx- <strong>True</strong></li><li>Click on <strong>Add</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e0uVqck0Rio2Wng-rg9PKw.png" /></figure><p>Click on <strong>Save</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yJiLlYeRsOATGrZwfwS4iA.png" /></figure><h3>5. Developing the front-end with gasless transactions</h3><p>Now we will develop a front-end to interact with our deployed GineteToken using meta/gasless transactions</p><p>Now let’s create <strong>GineteToken.json</strong> inside the <strong>src</strong> folder in your working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/341166d476df46043c95f403b00dc4a3/href">https://medium.com/media/341166d476df46043c95f403b00dc4a3/href</a></iframe><p>This file contains the ABI for the GineteToken. We will be needing it to interact with the token in upcoming steps.</p><p>Now let’s edit <strong>App.js</strong> inside the <strong>src</strong> folder in your working directory. Please replace the contents of the file with this one.</p><ol><li>Add the necessary imports</li></ol><pre>// src/App.js</pre><pre>import React from &quot;react&quot;;<br>import Biconomy from &quot;@biconomy/mexa&quot;;</pre><p>2. Initialize constants</p><pre>const abi = require(&quot;./GineteToken.json&quot;).abi;<br>const Web3 = require(&quot;web3&quot;);<br>const sigUtil = require(&quot;eth-sig-util&quot;);<br>// GineteToken contract address<br>const contractAddress = &quot;<strong>0xc9fa015042CE672ffAC9761206504967A128fb59</strong>&quot;; <br>const biconomyAPIKey = &#39;&#39;;  // Biconomy api key from the dashboard  const parentChainId = &#39;3&#39;; // chain id of the network <br>const maticProvider = &#39;https://testnetv3.matic.network&#39;</pre><p>3. Define EIP712 domain params</p><pre>const domainType = [     <br>      { name: &quot;name&quot;, type: &quot;string&quot; },     <br>      { name: &quot;version&quot;, type: &quot;string&quot; },<br>      { name: &quot;chainId&quot;, type: &quot;uint256&quot; },<br>      { name: &quot;verifyingContract&quot;, type: &quot;address&quot; }<br>];<br>const metaTransactionType = [<br>     { name: &quot;nonce&quot;, type: &quot;uint256&quot; },<br>     { name: &quot;from&quot;, type: &quot;address&quot; },<br>     { name: &quot;functionSignature&quot;, type: &quot;bytes&quot; }<br>];<br>let domainData = {<br>     name: &quot;GineteToken&quot;,<br>     version: &quot;1&quot;,<br>     chainId: parentChainId,<br>     verifyingContract: contractAddress   <br>};</pre><p>4. Enable metamask &amp; initialize Web3 providers (metamask in page provider for web3 and biconomy provider for getWeb3)</p><pre>window.ethereum.enable().catch(error =&gt; {<br>     console.log(error); <br>});<br>const web3 = new Web3(window.ethereum); <br>const biconomy = new Biconomy(<br>   new Web3.providers.HttpProvider(maticProvider),<br>   {<br>       apiKey: biconomyAPIKey,<br>       debug: true     <br>   }   <br>); <br>const getWeb3 = new Web3(biconomy);  <br>biconomy<br>     .onEvent(biconomy.READY, () =&gt; {<br>        console.log(&quot;Mexa is Ready&quot;);<br>     })<br>     .onEvent(biconomy.ERROR, (error, message) =&gt; {<br>        console.error(error);<br>     });</pre><p>5. Initialize contract object and define params</p><pre>const contract = new getWeb3.eth.Contract(abi, contractAddress); const amount = &quot;1000000000000000000&quot;;<br>const recipient = &quot;Add your recipient address here&quot;;</pre><p>6. Define functions to execute the transaction</p><pre>const metaTransfer = async () =&gt; {<br>   let functionSignature = contract.methods<br>     .transfer(recipient, amount)<br>     .encodeABI();<br>   executeMetaTransaction(functionSignature); <br>};  <br>const executeMetaTransaction = async functionSignature =&gt; {<br>   const accounts = await web3.eth.getAccounts();<br>   let userAddress = accounts[0];<br>   let nonce = await contract.methods.getNonce(userAddress).call();<br>   let message = {};<br>   message.nonce = parseInt(nonce);<br>   message.from = userAddress;<br>   message.functionSignature = functionSignature;<br>   const dataToSign = JSON.stringify({<br>       types: {<br>         EIP712Domain: domainType,<br>         MetaTransaction: metaTransactionType<br>       },<br>       domain: domainData,<br>       primaryType: &quot;MetaTransaction&quot;,<br>       message: message<br>     });</pre><pre>     web3.eth.currentProvider.send(<br>       {<br>         jsonrpc: &quot;2.0&quot;,<br>         id: 999999999999,<br>         method: &quot;eth_signTypedData_v4&quot;,<br>         params: [userAddress, dataToSign]<br>       },<br>       function(error, response) {<br>         <br>          let { r, s, v } = getSignatureParameters(response.result);<br>          <br>           const recovered = sigUtil.recoverTypedSignature_v4({<br>             data: JSON.parse(dataToSign),<br>             sig: response.result<br>           });<br>           let tx = contract.methods<br>           .executeMetaTransaction(userAddress, functionSignature,<br>            r, s, v)<br>           .send({<br>             from: userAddress<br>           });<br>       }<br>     );<br>   };</pre><pre>    const getSignatureParameters = signature =&gt; {<br>     if (!web3.utils.isHexStrict(signature)) {<br>       throw new Error(<br>         &#39;Given value &quot;&#39;.concat(signature, &#39;&quot; is not a valid hex<br>          string.&#39;)<br>       );<br>     }<br>     var r = signature.slice(0, 66);<br>     var s = &quot;0x&quot;.concat(signature.slice(66, 130));<br>     var v = &quot;0x&quot;.concat(signature.slice(130, 132));<br>     v = web3.utils.hexToNumber(v);<br>     if (![27, 28].includes(v)) v += 27;<br>     return {<br>       r: r,<br>       s: s,<br>       v: v<br>     };<br>   };</pre><p>7. Define App() function</p><pre>function App() {<br>   return (<br>     &lt;div&gt;<br>       &lt;h3&gt; MetaToken &lt;/h3&gt;<br>         &lt;React.Fragment&gt;<br>           {&quot;&quot;}<br>           &lt;button onClick={() =&gt; metaTransfer()} size=&quot;small&quot;&gt;<br>             Transfer<br>           &lt;/button&gt;<br>         &lt;/React.Fragment&gt;<br>     &lt;/div&gt;<br>   );<br> }<br> export default App;</pre><p>You can find the <strong>App.js</strong> code <a href="https://gist.github.com/sameepsi/e136e0aa3ed16389222a534e062c29d7">here</a></p><p>8. Run your application</p><p>Open a new console and perform the following steps.</p><pre>&gt; cd ~/tutorials/meta-tx<br>&gt; npm start</pre><p>Now your app should be running on <a href="http://localhost:3000/">http://localhost:3000</a></p><p>Thanks for reading the article. I hope it was useful for you.</p><blockquote>If you are looking out for Blockchain consulting or development services then reach out to us at <strong>info@ginete.in </strong>or drop your query on our <a href="https://www.ginete.in/contact-us/"><strong>website</strong></a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfae7ae8e743" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ginete-technologies/gasless-meta-transactions-on-matic-using-biconomy-bfae7ae8e743">Gasless/Meta transactions on Matic using Biconomy</a> was originally published in <a href="https://medium.com/ginete-technologies">Ginete Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DApp development with ethers.js]]></title>
            <link>https://medium.com/ginete-technologies/dapp-development-with-ethers-js-25872ccd7db7?source=rss-737d685e908d------2</link>
            <guid isPermaLink="false">https://medium.com/p/25872ccd7db7</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethersjs]]></category>
            <dc:creator><![CDATA[Sameep singhania]]></dc:creator>
            <pubDate>Wed, 24 Jul 2019 13:44:27 GMT</pubDate>
            <atom:updated>2019-07-25T08:54:45.042Z</atom:updated>
            <content:encoded><![CDATA[<p>The <strong>ethers.js</strong> library is an alternative to both <a href="https://github.com/ethereum/web3.js/">web3.js</a> and <a href="https://github.com/ethereumjs">EthereumJS</a> and is designed to make it easier to interact with Ethereum Blockchain. It aims to be highly maintained, flexible, complete and compact library to interact with Ethereum Blockchain. Currently, the codebase of ethers.js looks more structured and maintained as compared to web3.js.</p><p>In this article, we will learn how to write a DApp using ethers.js. It will be followed by more advanced articles related to ethers.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IByAxvcYvZUM0NyoN195Vg.jpeg" /></figure><p>In this article, we will create a simple <strong>EthereumBank</strong>. In this EthereumBank the users can perform the following actions-:</p><ol><li>Deposit ethers</li><li>Withdraw their ethers</li><li>Check their account balance</li></ol><p>This post is divided into the following 4 sections-:</p><ol><li>Setting up the development environment</li><li>Developing the Smart Contract</li><li>Deploying the smart contract to locally running test node(ganache)</li><li>Interacting with the contract using ethers.js and nodejs</li></ol><h3>1. Setting up the development environment</h3><p>The setup instructions are tested on Ubuntu 16.04 LTS. But they should work fine for macOS as well.</p><p>Open a new terminal.</p><pre>&gt; sudo apt-get update<br>&gt; curl -sL <a href="https://deb.nodesource.com/setup_8.x">https://deb.nodesource.com/setup_8.x</a> -o nodesource_setup.sh<br>&gt; sudo bash nodesource_setup.sh<br>&gt; sudo apt-get install nodejs<br>&gt; npm install -g ganache-cli<br>&gt; npm install -g solc@0.5.7<br>&gt; ganache-cli</pre><p>This will install nodejs, solcjs , ganache-cli and will start ganache-cli on port 8545.</p><p>DO NOT CLOSE THE ABOVE TERMINAL.</p><p>Open a new terminal and perform these steps</p><pre>&gt; cd ~<br>&gt; mkdir -p tutorial/ethers/01<br>&gt; cd tutorial/ethers/01<br>&gt; npm init<br>&gt; npm install ethers fs --save</pre><p>The above commands will do the following-:</p><ol><li>Create a new directory <strong>tutorial/ethers/01</strong>. From now we will call this directory our working directory</li><li>Initialize the nodejs project inside our working directory</li><li>Install <strong>ethers.js</strong> and <strong>fs</strong> node packages</li></ol><h3>2. Developing the Smart Contract</h3><p>Now create EthereumBank.sol file in the working directory with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59ce7621932fe594e384b9c0eea2a671/href">https://medium.com/media/59ce7621932fe594e384b9c0eea2a671/href</a></iframe><p>EthereumBank contract allows users to deposit and withdraw ethers. It also provides a function to check the balance of a user. Please read inline comments.</p><h3>3. Deploying the smart contract to the local node</h3><p>To deploy EthereumBank smart contract we will have to follow these steps-:</p><ol><li>Compile the contract</li><li>Deploy the contract on the local node</li></ol><p>Now let’s compile our contract. Follow the commands below to compile our contract. Run these commands inside the working directory.</p><pre>&gt; solcjs --bin --abi EthereumBank.sol</pre><p>The above command will compile your EthereumBank contract and the compiler will output 2 files. Let’s have a look at them-:</p><ol><li><strong>EthereumBank_sol_EthereumBank.bin</strong>- This is the compiled byte code of your contract and will be deployed to the blockchain.</li><li><strong>EthereumBank_sol_EthereumBank.abi</strong>- This file contains the template of the contract. It is required whenever you want to interact with the deployed contract</li></ol><p>Now let’s deploy our compiled contract on the blockchain, in our case local ganache node. Before running the next steps please ensure that a ganache instance is running in your terminal.</p><p>Now go to your working directory and create <strong>index.js</strong> file with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f89a5af2cb9fb41ba56d17a7dba2a929/href">https://medium.com/media/f89a5af2cb9fb41ba56d17a7dba2a929/href</a></iframe><p>This will initialize the network provider to connect to the local node. We are using <strong>JsonRpcProvider</strong> to achieve that. Now we need to add the compiled bytecode and abi files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d527db54de4dbbcec8cb059564470481/href">https://medium.com/media/d527db54de4dbbcec8cb059564470481/href</a></iframe><p>Now we have provider, bytecode and abi files for the contract. The next step will be to initialize the signer/wallet which will be used to deploy the contract. Once we have the signer we will initialize the contract factory and will deploy the contract.</p><p>Please, create a new method <strong>deploy()</strong> within your index.js file with the following contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/865fff9b64046ce6d20638a39d6362c4/href">https://medium.com/media/865fff9b64046ce6d20638a39d6362c4/href</a></iframe><p>Now let’s stop writing code and execute what we have written so far. Please execute below commands in the terminal inside your working directory.</p><pre>&gt; node index.js<br>&gt; 0x0C731D36AFE0B16aFe9F3D01C65E761C05047C7D</pre><p>Running above command will print an Ethereum address in the console. This is the address of the contract which we just deployed. So finally we are able to deploy our EthereumBank contract using ethers.js.</p><h3>4. Interacting with the contract</h3><p>Now we will interact with our deployed contract. As we know our contract has the following 3 methods-:</p><ol><li>deposit</li><li>withdraw</li><li>getUserBalance</li></ol><p>We will call each one of these methods using ethers.js. Please create <strong>interactWithBank</strong> method within your index.js file with the following contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d592bfb599a04bff7b69242f0c665af/href">https://medium.com/media/0d592bfb599a04bff7b69242f0c665af/href</a></iframe><p>The code within the <strong>interactWithBank </strong>method does the following-:</p><ol><li>Deploy the contract (line- 28)</li><li>Connects to the deployed contract using contract address, abi and current provider (line- 30)</li><li>Setup the wallet using which call to the smart contract will be made(line- 31)</li><li>Connects the wallet to the contract(line- 33)</li><li>Fetches balance of the user/address from the contract. Please note that here we have not provided any user/address to the method. The address associated with the wallet set in the previous step will be considered and balance of that particular user/address will be returned(line- 35)</li></ol><p>Now let’s test our code by running the below mentioned command in the terminal inside our working directory.</p><pre>&gt; node index.js<br>&gt; 0</pre><p>Running above command will return 0 as the user has not deposited any ethers in the bank so far. Now let’s deposit some ethers in the bank for the user. Please update the <strong>interactWithBank </strong>with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b044852b4fd5258a95d9c1f83b08418/href">https://medium.com/media/3b044852b4fd5258a95d9c1f83b08418/href</a></iframe><p>The additional code in <strong>interactWithBank</strong> method does the following-:</p><ol><li>Set up an additional parameter for the contract which specifies the amount of ethers to send with the call. The user wants to deposit 1 ETHER and hence we have set the value to be 1.0 ETH. The contract can accept more additional parameters which include- gasLimit, gasPrice, nonce, chainId.(line- 39–41)</li><li>Sends the transaction to deposit ethers by calling the <strong>deposit</strong> method of the contract. It will return the entire transaction object, you can print it out to see what is there in that object(line- 42)</li><li>Prints the hash of the transaction(line- 43)</li><li>Fetches the balance of user/address(line- 45)</li><li>Prints the balance on console(line- 46)</li></ol><p>Now let’s test our code by running below mentioned command in the terminal inside our working directory.</p><pre>&gt; node index.js<br>&gt; 0<br>&gt; 0xb2a7f5b927f8adbed371c876765410c2d04dcf8bf56e21b38c6f82427a3ff959<br>&gt; 1.0</pre><p>Running the above mentioned command will print the following on the console-:</p><ol><li>Initial balance of the user which is 0</li><li>The hash of the deposit transaction</li><li>The new balance of the user which is 1.0</li></ol><p>Now let’s withdraw some ethers from the bank for the user. Please update the <strong>interactWithBank </strong>with the below contents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/873bd078cadbd7a7148ab7a4b4a4a472/href">https://medium.com/media/873bd078cadbd7a7148ab7a4b4a4a472/href</a></iframe><p>The additional code in <strong>interactWithBank</strong> method does the following-:</p><ol><li>Sends the transaction to withdraw ethers by calling the <strong>withdraw</strong> method of the contract. In this method, we are passing a parameter which tells the bank how much ethers to withdraw. In our case, it is 0.9 ETH. It will return the entire transaction object, you can print it out to see what is there in that object(line- 48)</li><li>Prints the hash of the transaction(line- 49)</li><li>Fetches the balance of user/address(line- 51)</li><li>Prints the balance on console(line- 52)</li></ol><p>Now let’s test our code by running below mentioned command in the terminal inside our working directory.</p><pre>&gt; node index.js<br>&gt; 0<br>&gt; 0x8481ea0adcf7fb97ce16cd0918f3c3dedc88de0b8349c5400d78d0f9d47a93cf<br>&gt; 1.0<br>&gt; 0xbe62055c99d186a0b6e27cc6ac0271ffb46ebafac5a643c1605bb59485e8551b<br>&gt; 0.1</pre><p>Running the above mentioned command will print the following on the console-:</p><ol><li>Initial balance of the user which is 0</li><li>The hash of the deposit transaction</li><li>The new balance of the user which is 1.0</li><li>The hash of the withdraw transaction</li><li>The new balance of the user which is 0.1</li></ol><p>Thanks for reading the article. I hope it was useful for you.</p><blockquote>If you are looking out for Blockchain consulting or development services then reach out to us at <strong>info@ginete.in </strong>or drop your query on our <a href="https://www.ginete.in/contact-us/"><strong>website</strong></a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25872ccd7db7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ginete-technologies/dapp-development-with-ethers-js-25872ccd7db7">DApp development with ethers.js</a> was originally published in <a href="https://medium.com/ginete-technologies">Ginete Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Positive side of negative energy]]></title>
            <link>https://medium.com/citta/positive-side-of-negative-energy-360c90eb464b?source=rss-737d685e908d------2</link>
            <guid isPermaLink="false">https://medium.com/p/360c90eb464b</guid>
            <category><![CDATA[negativity]]></category>
            <category><![CDATA[introspection]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[positivity]]></category>
            <dc:creator><![CDATA[Sameep singhania]]></dc:creator>
            <pubDate>Thu, 18 Jan 2018 08:38:33 GMT</pubDate>
            <atom:updated>2018-01-18T08:38:33.098Z</atom:updated>
            <content:encoded><![CDATA[<p>It was yesterday when a sudden burst of negative thoughts hit me all of sudden, out of nowhere. I was depressed, stressed, angry and what not. I just wanted to sit and cry, unfortunately tears wouldn’t come out. My soul was looking for someone to spit out all the negative energy inside of me, but unfortunately couldn’t find anyone.<br>It went on for the entire day and I couldn’t sleep properly. All these thoughts of regret, failures etc. kept popping up for the entire day.<br>I fought with my loved ones, fought with myself but couldn’t get out of it. It became worse with each passing moment.<br>When I woke up in the morning, after last night’s disastorous sleep, the thoughts were still there and I was pissed off. I started introspecting why at the first place I am clogged by these thoughts? And then I realized it was my attitude, the mistakes which I did in the past and the failure to achieve what I wanted to achieve is allowing the negative energy to rule over my mind, my consciousness.<br>I started making list of all such things so that I can improve upon it to tackle the negative side or energy. Just when I was making the list and looking out for the solutions to change my attitude, improve upon my mistakes and chose a path to walk upon in order achieve what I always wanted to achieve, I felt negative energy is drowning away and the positive enegry taking the fron seat. :). Than a certain questions arised in my mind-:</p><ol><li>Is negative energy really bad?</li><li>Do we require negative energy for course correction?</li><li>Or is it just about tackling negative energy, looking out for the causes and fix them?</li><li>Is negative energy more powerful then positive energy, I mean the sudden burst of it?<br>When I started looking out for the answers to these questions, I felt as if I already have these answers within my subconscious mind.-:</li><li>Yes negative enegry is actually good for us.</li><li>Yes we do require negative energies for the course correction.</li><li>Yes it is only about handling the negative energy and converting it to positive energy.</li><li>Yes negative energies are more powerful than positive energies because it can make you do things which you otherwise though is impossible for you to do, you just have to look out for the answers instead of feeling depressed and stressed.</li></ol><p>So guys if it isn’t for the sudden burst of the negative energy I wouldn’t be writing this post, I wouldn’t have <strong>introspected</strong>, I wouldn’t have realized what I have been <strong>missing</strong>, I wouldn’t have realized how <strong>lazy</strong> I am, I wouldn’t have given a thought on what I actually <strong>want in life</strong>, I wouldn’t have realized the need to <strong>let go</strong> of few things in my life and the biggest of all the amount of <strong>positive energy</strong> which I have now wouldn’t be there.<br>So guys embrace negativity as you embrace night after day, just hang around it for long enough and it will pass away as does the night.<br>Whenever you are under suddent burst of negative thoughts, embrace them and look out for- the reasons behind it, introspect how it can be fixed and start working on it. You will feel as if the entire cover of negativity is suddenly being turned into positivity and now you have more zeal and ethusiasm to work towards your life goal.<br><strong>Positive Energy Generated Out of Negative Energy is the powerful of all that is there of the Creation.</strong><br><strong>It is we who creates the Universe surrounding us.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=360c90eb464b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/citta/positive-side-of-negative-energy-360c90eb464b">Positive side of negative energy</a> was originally published in <a href="https://medium.com/citta">citta</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>