<?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 Parishilan Rayamajhi on Medium]]></title>
        <description><![CDATA[Stories by Parishilan Rayamajhi on Medium]]></description>
        <link>https://medium.com/@parishilanrayamajhi?source=rss-87165d5a1c88------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xMlh1tuM3AtYmitcWLCpfA.jpeg</url>
            <title>Stories by Parishilan Rayamajhi on Medium</title>
            <link>https://medium.com/@parishilanrayamajhi?source=rss-87165d5a1c88------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 27 May 2026 09:12:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@parishilanrayamajhi/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[Switching to ECS from EKS reduced our server cost by 40%]]></title>
            <link>https://medium.com/@parishilanrayamajhi/switching-to-ecs-from-eks-reduced-our-server-cost-by-40-26538df23eb6?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/26538df23eb6</guid>
            <category><![CDATA[deployment-model]]></category>
            <category><![CDATA[elastic-container-service]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Tue, 16 Aug 2022 12:37:48 GMT</pubDate>
            <atom:updated>2022-08-19T15:52:03.252Z</atom:updated>
            <content:encoded><![CDATA[<p>For the past 1 year, I have been building a complex distributed microservice application. <em>Our client had their working system which was serving their need but as the user base grew, their existing seems to be giving multiple issues. </em>So they approached us to make their system highly scalable, fast, and responsive.</p><p>Our system was based on the following stacks:</p><pre>Frontend: Reactjs<br>Backend: Nodejs<br>Architecture: Microservices<br>db: AWS RDS: Mysql<br>Deployment :Amazon Elastic Kubernetes Service<br>Queue service : Rabbit Mq (for eventbased approach)<br>Elastic Search for CQRS approach to store complex recurring datas<br>Auth0 <br>Docker<br>Jenkins : CI/CD<br>AWS ECR : ECR, for pushing docker images from jenkins<br>AWS ECS :Elastic Container Service <br>Inter service communication : GRPC protocol</pre><p>How were we deploying our application?</p><p>We have 6 services dedicated to the inventory management system where I was Leading the team of 4 backend developers and 1 DevOps. I was supposed to take the technical decision. The development process was pretty clear :</p><ul><li>Developers work in their personal branch , they send Merge Requests to develop branch</li><li>Ones merged in develop , CI/Cd triggered creating the docker image of service and pushing it to ECR</li><li>Jenkins triggered EKS build process. EKS was pre-setup and was served with Helm, deploying the application</li></ul><blockquote><strong>EKS</strong> removes the need to architect high availability and scalability for our master nodes. EKS automates load distribution and parallel processing faster and efficiently.</blockquote><blockquote>The <strong>Helm </strong>is a package manager for Kubernetes helps you install and manage applications on your Kubernetes cluster using which we can install and manage charts using the Helm CLI on our EC2 instances.</blockquote><h3>This was doing the job fine but seems like EKS is very expensive. It was $ 3448.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DrH2Ar1pFW1AnKFCtQgDtw.png" /><figcaption>Month End cost (AWS)</figcaption></figure><p>As a team lead, I had to take care of both the business and technical sides. When it was serving fine with EKs it was very expensive on the other hand. I needed to find a better solution for it, this was then I got a chance to look into ECS.</p><blockquote><strong>Amazon ECS</strong> is a fully managed container orchestration service that makes it easy for you to deploy, manage, and scale containerized applications.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbvhwOw5bbp7jL5yEZ7g_A.png" /><figcaption>ECS architecture</figcaption></figure><h3>Why did I choose ECS over EKS?</h3><h4>Pricing:</h4><p>It depends on the number of clusters needed for application deployment. On EKS, you pay a fee of $0.10 per hour for each cluster you operate. ECS is likely to cost significantly less because there are no per-cluster charges.</p><h4><strong>Networking</strong></h4><p>EKS provides a better networking configuration when running on EC2 instances but when your containerized application will run on Fargate, ECS will just do the work fine. There was nothing much we could lose by switching to EKS</p><h4><strong>Simplicity</strong></h4><p>As I was in the middle of a running project, we could not lose a lot of time in learning the new process from scratch. ECS was very easy to build, deploy, or migrate our containerized applications.</p><p>For example, if you need a load balancer, AWS Application Load Balancer (ALB) integrates seamlessly with Amazon ECS.</p><h4>Auto-scaling:</h4><p>We can define the number of tasks we want to run during service configuration. Increase or decrease the number of tasks that your service runs based on a target value.</p><p>ECS Deployment works in 3 basic steps.</p><ol><li><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-task-definition.html">Defining task</a></li><li><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service.html">Defining service</a></li><li><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html">Define env variable</a></li><li>Deploy</li></ol><p><strong>This is the difference in cost we experienced after a month of switching to ECS.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IzJQXxzqz1Zl-WRxTHoOWg.png" /><figcaption>Server Costing after a month of ECS usage</figcaption></figure><p><strong>My Conclusion</strong></p><p>EKS could be better in many ways but ECS with Fargate did work just fine as per my project need.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26538df23eb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Apple ignored my replacement Request to their faulty Device]]></title>
            <link>https://medium.com/@parishilanrayamajhi/how-apple-ignored-my-replacement-request-to-their-faulty-device-e520cf861e46?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/e520cf861e46</guid>
            <category><![CDATA[macbook-pro]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[apple-warranty]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 19:07:28 GMT</pubDate>
            <atom:updated>2022-08-12T19:07:28.119Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Summary </strong><br> 1. Problems so far: <br> 2. Apple Support Journey and how they ignored my replacement request<br> 3. Unnecessary trouble Apple support gave me</p><p><strong>Problems so far: <br></strong><a href="https://twitter.com/parishilan13/status/1525765266864414720?s=20&amp;t=aThgxudAIJsrfADtLueMRQ"><strong> 1. </strong>Keyboard issue: video here <br></a><a href="https://twitter.com/parishilan13/status/1555485658394701826?s=20&amp;t=aThgxudAIJsrfADtLueMRQ">2. Distorted Sound: video here <br></a><a href="https://twitter.com/parishilan13/status/1554666993592086528?s=20&amp;t=aThgxudAIJsrfADtLueMRQ">3. MagSafe not working: video here <br></a>4. The device stopped charging with the new charger too<br> <br> <br>It has been a very bad experience so far with Mac Book Pro 14&quot; as well as Apple Support Staff. The problem started after 5 months of buying this laptop on 28 Dec 2021.<br> <br>First was the keyboard Issue which you can check <a href="https://twitter.com/parishilan13/status/1525765266864414720?s=20&amp;t=aThgxudAIJsrfADtLueMRQ">here</a>: (May 2022)</p><p><strong>Issues</strong>: <br><strong> </strong><a href="https://twitter.com/parishilan13/status/1525765266864414720?s=20&amp;t=aThgxudAIJsrfADtLueMRQ"><strong>1. Mistyped keys as shown in the video </strong></a><strong><br></strong>weird key noise <br> <br>I went to this Apple service center, diagnosed the test, and find out that it was some inbuilt issue with hardware and since the device was under warranty they replaced the new keyboard. <br> <br><a href="https://twitter.com/parishilan13/status/1555485658394701826?s=20&amp;t=aThgxudAIJsrfADtLueMRQ"><strong>2. Distorted Sound from Speake: check the video here </strong></a><strong><br></strong> <br>This was discovered along with the above-mentioned keyboard issue, which they told will be fixed along with the keyboard, but it never happened. <br>This is so irritating, you get such weird noise every time you play some music or video/voice call using this device <br> <br><a href="https://twitter.com/parishilan13/status/1554681820003704833?s=20&amp;t=aThgxudAIJsrfADtLueMRQ"><strong>3. Flickering Display: check the video here </strong><br></a> <br>Isn’t it so irritating to see such flickers on your screen all the time when you use your device? <br> <br><strong>4. Mag Safe stopped charging: </strong><a href="https://twitter.com/parishilan13/status/1554666993592086528?s=20&amp;t=aThgxudAIJsrfADtLueMRQ"><strong>video here</strong></a></p><p>When there were already soo many issues with this device, it stopped charging.</p><p><strong>5. Device was not charging with any other charger as well</strong></p><p><em>My experience throughout the process till today: from May 2022 to Aug 2022<br></em> <br>After I noticed the first issue discovered 5 months after purchase of the new MBP pro 14&quot;, I went to<em> </em><a href="https://evostore.com.np/"><em>Apple support based in Kathmandu, Nepal.</em></a> They did some internal testing and found out that there was some inbuilt issue with the keyboard. It took 3 weeks for them to replace the new keyboard. 3 weeks without a laptop for someone working in the IT field is a big issue. I work on this laptop for more than 8 hrs a day and it was not easy for me to manage a replacement device to work on. <br> <br>Now, the keyboard was working fine after a replacement but the distorted speaker persists, which I considered and move on. After some time, the display starts flickering. I was very frustrated at this point. I again went to the same customer care, they told me to contact Apple support as I was asking if my faulty device could be replaced as there were multiple issues arising within 6 months of buying it. <br> <br>I was assigned this <strong>ticket number ==&gt; 101707747857</strong> and appointed me a senior technical assistant. They said they won’t be able to call me in my current location i.e Nepal so asked me to go to India, Banglore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*UrIOoeEXc2c5aSwRdjAuzw.png" /><figcaption>Gives you a perspective of my next journey I was about to cover just because apple could not help me with phone assistance in my country</figcaption></figure><p>Can you imagine, for just phone support, I had to make arrangements to go to India? I did all of it, visa processing, flight ticket, accommodation, and went to India with the hope of getting justice for this device. <br> <br>First, I went to a <a href="https://www.google.com/search?q=iplanet%20bangalore&amp;oq=iplanet+banglore&amp;aqs=chrome..69i57j0i10j69i59j0i10j0i10i457j0i10l4j0i390.2378j0j4&amp;sourceid=chrome&amp;ie=UTF-8&amp;tbs=lrf:!1m4!1u3!2m2!3m1!1e1!2m1!1e3!3sIAE,lf:1,lf_ui:4&amp;tbm=lcl&amp;sxsrf=ALiCzsbvvpTcoT2fHj4Z5YPiVH877mNEbg:1660330824368&amp;rflfq=1&amp;num=10&amp;rldimm=5890563993747209849&amp;lqi=ChFpcGxhbmV0IGJhbmdhbG9yZSIDiAEBSMzJ6abOrYCACFodEAAYACIRaXBsYW5ldCBiYW5nYWxvcmUqBAgCEACSARBjZWxsX3Bob25lX3N0b3JlqgEPEAEqCyIHaXBsYW5ldCgA&amp;ved=2ahUKEwiM3fun_sH5AhVf33MBHTjDBaIQvS56BAgLEAE&amp;sa=X&amp;rlst=f#rlfi=hd:;si:5890563993747209849,l,ChFpcGxhbmV0IGJhbmdhbG9yZSIDiAEBSMzJ6abOrYCACFodEAAYACIRaXBsYW5ldCBiYW5nYWxvcmUqBAgCEACSARBjZWxsX3Bob25lX3N0b3JlqgEPEAEqCyIHaXBsYW5ldCgA;mv:[[13.0375261,77.7384398],[12.8669335,77.5398242]];tbs:lrf:!1m4!1u3!2m2!3m1!1e1!2m1!1e3!3sIAE,lf:1,lf_ui:4"><em>support center</em></a> near my hotel, but they refused to take my device for my replacement request see the <a href="https://twitter.com/parishilan13/status/1556241173656010752?s=20&amp;t=aThgxudAIJsrfADtLueMRQ">video here</a>. I believe they should have been empathetic rather than showing such behavior as this is very basic we expect from Apple. They were harsh with their behavior and I was all alone. Some of their customers came to support me and speak in my favor, which you can hear in the background of this video. Since I was not allowed to make the video, I did an audio recording which I can release if someone wants to hear the full conversation.</p><p>I came back to the hotel and reach out to Apple support Via the chatting system and told them about my problem. One of them asked me to arrange a sim card so that they can assign a senior consultant to call me. It took me 4+ days to arrange the sim card and when I reach them back with a phone number, they asked me to perform some basic stuff which they guided me over the support chat itself, and for the time being those issues went off.</p><p>Probably this should have been the very first step rather than me flying abroad with the hope of getting phone support where the problem was fixed via the chat support itself. I don’t know why there was no coordination among the support staff because of which I had to go through unnecessary trouble.</p><p>I returned back home thinking at least my problem is now resolved.</p><p>But, after 3 weeks of using this device, all of these issues started again.</p><p>I was helpless and was doing nothing until my charger stopped charging my device. Again took the device to a support center based in Kathmandu, and showed them that it was no longer charging my device. They tried with their charger and still, it was not charging so they asked me to leave my device to them so that they can test further.</p><p>I got a call after 2 days from them i,e today 12 Aug 2022 saying no issue encountered again. The same employee who tested my device before asking me to leave it to them said they are not able to reproduce the same issue so they are returning it back to me without any action.</p><p>What am I supposed to do in this case?</p><p>As per this <a href="https://www.apple.com/legal/warranty/products/accessory-warranty-english.html#:~:text=The%20Apple%20One-Year%20Limited%20Warranty%20is%20a%20voluntary,not%20limited%20to%20those%20relating%20to%20non-conforming%20goods.">link&#39;s</a> 2nd and 3rd points, I believe I should get a replacement. Or is it a geographical barrier that is stopping them to extend replacement services or even phone call services to my country?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*G-WwBeHmhksHEJlkQfH_Bg.png" /><figcaption>Apple One (1) Year Limited Warranty.</figcaption></figure><p>Someone, please suggest to me what shall I do next. I hope you understand my frustration.</p><p>Kind Regards,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e520cf861e46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let's build Bitcoin Hd addresses!]]></title>
            <link>https://medium.com/@parishilanrayamajhi/lets-build-bitcoin-hd-addresses-89cf78e619f9?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/89cf78e619f9</guid>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Thu, 09 Dec 2021 09:32:25 GMT</pubDate>
            <atom:updated>2022-03-08T06:47:06.297Z</atom:updated>
            <content:encoded><![CDATA[<h3>Let’s build Bitcoin Hd addresses!</h3><p>Well, so it has been quite a time since I have last published something technical stuff here, yes there are so many of them in the draft which I will publish in a while. Most of them are under microservice architecture as for quite a time I have been involved in such a fascinating software development technique. There is a lot to share under that hood but for now, let’s get this Hd address thing done in bitcoin.</p><p>You can explore theoretical aspects of HD wallet in <a href="https://arshbot.medium.com/hd-wallets-explained-from-high-level-to-nuts-and-bolts-9a41545f5b0">this article here</a>. But in short, HD wallet is the approach of generating N number of bitcoin wallet using the same key phrase so-called as mnemonics.</p><h3>Private Key, Public Key, and bitcoin Address</h3><p>The<strong> private key </strong>provides a signature that proves you are the owner of a particular bitcoin address and is simply nothing but a random number generated between 1 to N-1 where N = 2²⁵⁶ (approx). If you ever thought about how the randomness is created, you should check <a href="https://www.bitaddress.org/bitaddress.org-v3.3.0-SHA256-dec17c07685e1870960903d8f58090475b25af946fe95a734f88408cef4aa194.html">this link</a>, where you are asked to randomly move your mouse cursor a number of times (which will create a random pattern which is no way going to be the same all the time you initiate the process ).<strong><em> We feed this random string to the </em></strong><a href="https://www.n-able.com/blog/sha-256-encryption#:~:text=SHA%2D256%20is%20a%20patented,that%20is%20256%20bits%20long.&amp;text=For%20example%2C%20a%20512%2Dbit,that%20makes%20it%20completely%20unreadable."><strong><em>sha256</em></strong></a><strong><em> hash algorithm and the output of 256 bit is our private key.</em></strong></p><p>The<strong> public key </strong>is a cryptographic key generated by <a href="https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication">Elliptic Multiplication on the private key</a></p><p>And <strong>address </strong>is the outcome of one-way hash function SHA256 applied over public key and <a href="https://en.wikipedia.org/wiki/RIPEMD">RIPEMD</a> applied over the result.</p><p><strong><em>i</em></strong>.e <strong>Public Key <em>= RIPEMD160(SHA256(Pvtkey))</em></strong></p><p>So much technical stuff right ?? let’s wrap it up with the following image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*Tz046meEhGIJ1ej_MQ_Kkw.png" /><figcaption>Public Key to Bitcoin Address: Conversion of a public key into a bitcoin ad‐ dress</figcaption></figure><p>I will be using Nodejs for this demo and We shall be using the following libraries :</p><pre>var bitcoinLib = require(&quot;bitcoinjs-lib&quot;);<br>var bip39 = require(&#39;bip39&#39;);<br>var bip32 = require(&#39;bip32&#39;);</pre><p><strong>bitcoinjs</strong> is a javascript Bitcoin library for node.js</p><p><strong>bip39 is </strong>mnemonic code for generating deterministic keys</p><p><strong>bip32 </strong>is the Bitcoin Improvement Proposal which introduced the standard of HD wallets and extended keys to Bitcoin.</p><p><strong><em>Mnemonics :</em></strong></p><p>Mnemonics are randomly generated 12 to 24 words from a fixed list of 2048 (proposed in <a href="https://en.bitcoin.it/wiki/BIP_0039">BIP39</a>)potential words. Each word is represented by an integer from 0 to 2047 corresponding to its position in the list. These random numbers are used as the seed used to derive a deterministic wallet.</p><p>You can generate seed with the following library :</p><pre>const mnemonic = bip39.generateMnemonic(); //generates string <br>const seed = await bip39.mnemonicToSeed(mnemonic);</pre><p>The mnemonics are used as a backup to regenerate the entire wallet family.</p><p><strong>HD path :</strong></p><p>Since our topic itself is HD which stands for Hierarchical Deterministic, we should be able to find some Hierarchy and that’s where the HD path comes into play. This is the hierarchy using which we can generate N number of addresses. Every coin has its own unique HD path which you can check out <a href="https://github.com/libbitcoin/libbitcoin-system/wiki/Altcoin-Version-Mappings">here</a>. For now, let’s check it for ETH and BTC,</p><pre>btc_test_hd_path = m/44&#39;/1&#39;/0&#39;/i<br>btc_main_hd_path = m/44&#39;/0&#39;/0&#39;/i<br>eth_hd_path = m/44’/60’/0’/i</pre><p>Now what is this fuss all about is &gt;&gt;</p><blockquote>m’ / purpose’ / coin_type’ / account’ / change / address_index</blockquote><p>For sure you have seen this a lot of times, but what is this all about ??</p><p>It is all about <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki">BIP0044</a> which proposes a multi-account structure as “purpose” number 44&#39;. All HD wallets following the BIP0044 structure are identified by the fact that they only used one branch of the tree: m/44&#39;/. So :</p><blockquote>purpose’ → always remains 44&#39;.</blockquote><blockquote>coin_type’ → for btc its 0/1 , for eth its 60, and you can find it for other altcoins <a href="https://github.com/libbitcoin/libbitcoin-system/wiki/Altcoin-Version-Mappings">here</a></blockquote><blockquote>account’ → This is your business need, let’s say the account I give to the public forum for donation is &gt; m/44&#39;/0&#39;/1 and for my personal use is m/44&#39;/0&#39;/0’</blockquote><blockquote>change → is for change address</blockquote><blockquote>address_index → is the index of Nth position of your generated address.</blockquote><p>Probably this is all theory is required for you to good to go with HD addresses. For sure it’s a never-ending topic, so ever you want to explore more on this topic I would highly recommend <a href="https://www.amazon.com/Mastering-Bitcoin-Programming-Open-Blockchain-ebook/dp/B071K7FCD4">Mastering Bitcoin</a>. This is the best book i have ever read.</p><p><em>Time for coding !!!!</em></p><pre>var index = 1 // this is address_index</pre><pre>const mnemonic = await bip39.generateMnemonic();</pre><pre>var hd_path = m/44&#39;/1&#39;/0&#39; // for testnet</pre><pre>const seed = await bip39.mnemonicToSeed(mnemonic);</pre><pre>const root = bip32.fromSeed(seed, network);</pre><pre>const account = root.derivePath(hd_path);</pre><pre>const accountXPub = account.neutered().toBase58();</pre><pre>const node = bip32.fromBase58(accountXPub, network);</pre><pre>const child = node.derive(0).derive(index);</pre><pre>const address = bitcoinLib.payments.p2pkh({ pubkey: child.publicKey, network }).address;</pre><pre>let pvtKey = account.derive(0).derive(index);<br>pvtKey = pvtKey.toWIF();  // this is the private key</pre><pre>const account_details = { address: address,  mnemonic : mnemonics, index: index});</pre><pre>console.log(account_details)</pre><p>output &gt;&gt;</p><pre>{<br>   &quot;address&quot;:&quot;mierjL7fxLE3QAoAn52EibxMDnorqUXqQM&quot;,<br>   &quot;index&quot;:8,<br>   &quot;mnemonic&quot;:&quot;index doll town issue reflect colla rose kiss zero  brass library town&quot;<br>}</pre><p>And this is it !!</p><p>You have address generated, the private key of it, the mnemonics , what all you need ? Now you can generate N number of such addresses and get to remember single thing i,e mnemonics .</p><p>This is the beauty of HD addresses.</p><p>Cheers for the life !!!</p><p>I will see you in next one!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89cf78e619f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying and Interacting with Smart Contract: Web3v1.2.1]]></title>
            <link>https://medium.com/@parishilanrayamajhi/deploying-and-interacting-with-smart-contract-web3v1-2-1-9b830e9c4eae?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b830e9c4eae</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Fri, 23 Aug 2019 18:03:31 GMT</pubDate>
            <atom:updated>2019-08-23T18:03:31.291Z</atom:updated>
            <content:encoded><![CDATA[<p>After the release of a new stable version of web3 1.2.1 things has changed a bit. This article will help you deploy and interact with a smart contract using latest web3v1.2.1</p><p>For instance, we will be using very simple smart contract</p><pre>pragma solidity ^0.4.25;</pre><pre>contract Test {    <br>    uint256 a;<br>    <br>    constructor (uint256 val) public {<br>         a = val;<br>    }<br>    <br>    function printAll() public view returns(uint256){<br>        return a;<br>    }</pre><pre>function setA(uint256 val) public {<br>        a = val;<br>    }<br>}</pre><p>Now let&#39;s deploy above contract using <strong>only web3 js</strong></p><h3>Deploy process</h3><p>1)Initializing the process</p><blockquote>1) First, we require web3js make sure to have installed the newest version. <br>Refer <a href="https://web3js.readthedocs.io/en/v1.2.1/">this</a> and <a href="https://medium.com/@samuel_91690/1-0-release-web3-js-ddd23d3c8f62">this</a> document for more details.</blockquote><blockquote>2) Since our contract will be fetched via a file(test.sol) we need filesystem (fs ) as well.</blockquote><blockquote>3) We will be using ganache cli for the deployment</blockquote><pre>const Web3 =  require(&#39;web3&#39;)  <br>const fs = require(&#39;fs&#39;);<br>const ganache_cli = &quot;<a href="http://localhost:8545">http://localhost:8545</a>&quot;;<br>var web3 = new Web3(Web3.currentProvider || ganache_cli);</pre><h4>2) compile the source code and fetch its abi and byte code</h4><pre>const sourceCode = fs.readFileSync(&#39;test.sol&#39;,&#39;utf8&#39;).toString();<br>const compiledCode =  compiler.compile(sourceCode,1).contracts[&#39;:Test&#39;]<br>const interface = JSON.parse(compiledCode.interface);<br>const bytecode =  compiledCode.bytecode;</pre><h4>3) deploy contract</h4><p>After you have bytecode and abi(in above code interfact is the abi) you are ready to go for deployment process all you need is a address which you can fetch from ganache account.</p><pre>function deploy_contract(){<br>    const myContract = new web3.eth.Contract(interface);<br>    myContract.deploy({data:bytecode,arguments:[45]}).send({<br>        from:&quot;0x1ca9e8C97cb0fA5Ec6b49DF7501A23212a4b9d2d&quot;,<br>        gas: 4700000<br>    },(err,res) =&gt; {<br>        if(err){<br>            console.log(err);<br>        }<br>        if(res){<br>            console.log(res);<br>        }<br>    })<br>    <br>}</pre><p>in the above code <strong><em>myContract.deploy() </em></strong><em>is the rpc we need to understand.</em></p><blockquote>It takes data as bytecode and if your constructor need to be passed some argument you need to pass here, IN our contract we need to pass uint as constructore argument so we are passing lets say 45 here,</blockquote><pre><strong>myContract.deploy({data:bytecode,arguments:[45]}).send({<br>        from:&quot;0x1ca9e8C97cb0fA5Ec6b49DF7501A23212a4b9d2d&quot;,<br>        gas: 4700000<br>    }</strong></pre><p>After you invoke <strong>deploy_contract() </strong>function you will get a txid in your console :</p><pre><strong>0xe744bf3462a0cbf4a35d9e33cf2150d435aef84cf6e499ca9905d87a14d2ac95</strong></pre><p>That mens your contract is deployed and you get the receipt of it.</p><p>to verify the receipt you can invoke RPC all <strong><em>getTransactionReceipt </em></strong><em>i.e</em></p><pre>const txid = &quot;0xe744bf3462a0cbf4a35d9e33cf2150d435aef84cf6e499ca9905d87a14d2ac95<strong>&quot;</strong></pre><pre>async function  getTransactionReceipt(){<br>const receipt =  await web3.eth.getTransactionReceipt(&quot;txid&quot;);<br>    console.log(receipt)<br>}</pre><p>which will give you the following output with your contract address:</p><pre>{ <br><strong>transactionHash:<br>   &#39;0xe744bf3462a0cbf4a35d9e33cf2150d435aef84cf6e499ca9905d87a14d2ac95&#39;,</strong><br>  transactionIndex: 0,<br>  blockHash:<br>   &#39;0xa7e82a28fb5a20534da240673ea192d84fc63a783f1dfe4a0933599ae4527972&#39;,<br>  blockNumber: 1,<br>  from: &#39;0x0d849ad6868eae598e02aac966680c5b6e2d2f76&#39;,<br>  to: null,<br>  gasUsed: 125097,<br>  cumulativeGasUsed: 125097,<br><strong>  contractAddress: &#39;0xD264C0F2Bfc6eb43c2e3C9a0A97363E4B3568C86&#39;,<br></strong>  logs: [],<br>  status: true,<br>  logsBloom:<br>   &#39;0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000&#39;,<br>  v: &#39;0x1b&#39;,<br>  r:<br>   &#39;0xac5c255178d065578f6d8597fe35642a9c8efd77325adf2f8f3a9b8c96c8de9f&#39;,<br>  s:<br>   &#39;0x74c27849e4d4fdb076fd63db5ea0b50522da08249530177cfcb43013c7792573&#39; }</pre><h3>Interact with contract</h3><p>First, create the contract interface of our deployed contract address with the given abi</p><pre>function interract_contract(){<br>   <strong> const contract_address = </strong>&quot;<strong>0xD264C0F2Bfc6eb43c2e3C9a0A97363E4B3568C86</strong>&quot;;<br>    const abi = interface;<br>    var contract_interfact = new web3.eth.Contract(abi,contract_address,{<br>     from: &quot;0x0aed251C576fF1214567cad627aBf4693243e45f&quot;,<br>     gasPrice: &#39;20000000000&#39;   <br>    });<br>}</pre><p>now using the newly created interface you will call the methods inside the contract, for now, we have 2 methods <strong>printall and setA </strong>which we will call in the following manner:</p><ol><li>printAll() → will print the value initialized in the constructor</li><li>setA(uint256) → will update the value</li><li>printAll() → to verify if value is updated</li></ol><p>we will be using <em>contract_interfact.methods</em>.<strong>method.</strong><em>call/send RPC :</em></p><pre>contract_interfact.methods.<strong>printAll().</strong>call({from:&quot;0xc00fF6eD9aa292BFA422D6E05eA7d7dc4336269c&quot;},(err,res) =&gt; {<br>        if(err){<br>            console.log(err);<br>        }else{<br>            console.log(&#39;constructor param before updating it is: &#39;+ res);<br>        }<br>    });</pre><pre>contract_interfact.methods<strong>.setA(356).</strong>send({from:&quot;0xc00fF6eD9aa292BFA422D6E05eA7d7dc4336269c&quot;}).then(function(receipt){<br>        console.log(receipt);<br>    });</pre><pre>contract_interfact.methods.<strong>printAll().</strong>call({from:&quot;0xc00fF6eD9aa292BFA422D6E05eA7d7dc4336269c&quot;},(err,res) =&gt; {<br>        if(err){<br>            console.log(err);<br>        }else{<br>            console.log(&#39;constructor param after updating it is  : &#39; +res);        }</pre><pre>});</pre><p>You will be getting the output as</p><pre>constructor param before updating it is: 45</pre><pre>constructor param after updating it is : 356</pre><p>Thats it!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b830e9c4eae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Insite explorer]]></title>
            <link>https://medium.com/@parishilanrayamajhi/insite-explorer-3aeec422401d?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aeec422401d</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[crypto-exchange]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Sat, 16 Mar 2019 09:40:02 GMT</pubDate>
            <atom:updated>2019-08-05T04:14:46.061Z</atom:updated>
            <content:encoded><![CDATA[<h3>cryptocurrency ticker widget ubuntu</h3><p>Ever wonder how much time you spend in a day watching at the price of various cryptos. I was one of you, so i thought of creating something that makes my life little easier,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*JLdEk801r5mPHJfNovl0qw.png" /></figure><pre>git clone <a href="https://github.com/bluppfisk/coinprice-indicator">https://github.com/bluppfisk/coinprice-indicator</a></pre><p><strong>create venv: my case coin_widget</strong></p><pre><em>1)virtualenv -p python3 venv_name</em></pre><p><strong><em>user in my case is parin</em></strong></p><blockquote>Find new python executable in /home/parin/Documents/parin/Documents/coinprice-indicator/coin_widget/bin/python3</blockquote><blockquote>Also creating executable in /home/parin/Documents/parin/Documents/coinprice-indicator/coin_widget/bin/python</blockquote><blockquote>cd /home/parin/Documents/parin/Documents/coinprice-indicator/coin_widget/bin</blockquote><p>Activate new virtual env with :</p><pre>source activate</pre><pre>(coin_widget) parin@paarin:~/Documents/parin/Documents/coinprice-indicator/coin_widget/bin$</pre><p><strong>Install</strong> dbus-python <strong>from following link &amp; follow user cryptoktm (yes thats me again)</strong></p><p><a href="https://stackoverflow.com/questions/13365697/install-python-dbus-in-virtualenv/13367493">Install Python-Dbus in virtualenv</a></p><p><strong>install further dependencies from requirement.txt in master branch</strong></p><pre>cat requirements.txt</pre><pre>install -r requirements.txt</pre><pre>pip freeze</pre><p>Ones required packages are insalled cross check the manager with</p><pre>pip freeze</pre><p>you should meet following dependencies:</p><pre><br>certifi==2018.8.24<br>chardet==3.0.4<br>dbus-python==1.2.8<br>idna==2.7<br>notify2==0.3.1<br>pycairo==1.17.1<br>pygame==1.9.4<br>PyYAML==3.13<br>requests==2.20.0<br>ruamel.base==1.0.0<br>ruamel.yaml==0.15.64<br>urllib3==1.23<br>vext==0.7.0<br>vext.gi==0.7.0<br>websockets==6.0<br>certifi==2018.8.24<br>chardet==3.0.4<br>dbus-python==1.2.8<br>idna==2.7<br>notify2==0.3.1<br>pkg-resources==0.0.0<br>pycairo==1.17.1<br>pygame==1.9.4<br>PyYAML==3.13<br>requests==2.20.0<br>ruamel.base==1.0.0<br>ruamel.yaml==0.15.64<br>urllib3==1.23<br>vext==0.7.0<br>vext.gi==0.7.0<br>websockets==6.0</pre><p>After the required settings, you are good to go with executing the executable with with:</p><pre>cd /home/parin/Documents/parin/Documents/coinprice-indicator ./run.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*JLdEk801r5mPHJfNovl0qw.png" /></figure><p>And if everything goes well shoud see a ticker strap on top of your desktop</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aeec422401d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitcoin Application: Bitcore setup guide]]></title>
            <link>https://medium.com/@parishilanrayamajhi/bitcore-documentation-53c9a6b33bd4?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/53c9a6b33bd4</guid>
            <category><![CDATA[bitcore]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[explorer]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Sat, 16 Mar 2019 09:39:05 GMT</pubDate>
            <atom:updated>2020-04-15T07:06:30.317Z</atom:updated>
            <content:encoded><![CDATA[<h3>Bitcoin Application: Bitcore</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*Jn5vPAPcqhuy2DRgze0djA.png" /></figure><p>Bitcore is a SAAS infrastructure that helps us to create Bitcoin-based application, allowing us to easily interact with Litecoin Blockchain. Litecore comes with a package allowing us to easily setup Litecoin full node and provides APIs to interact with it. Here is the list of the functionality provided by bitcore:</p><ol><li>Bitcoin wallet service (client and server)</li><li>Bitcoin explorer</li><li>Full node setup</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O0cwMLOJwX_qyyNI.png" /><figcaption>Bitcore Architecture</figcaption></figure><p><strong>Lets start with the setting up Bitcore in Ubuntu 16.04</strong></p><blockquote><em>1) Installing Nodejs v&gt;8.x</em></blockquote><p>There are soo many ways to deal with it, I will be guiding for the simplest one</p><p>a) Create nodesource.list</p><pre>sudo vim /etc/apt/sources.list.d/nodesource.list</pre><p>b) Add following lines(you can replace 8.x with whichever version of Nodejs you want to install)</p><pre>deb <a href="https://deb.nodesource.com/node_8.x">https://deb.nodesource.com/node_8.x</a> xenial main<br>deb-src <a href="https://deb.nodesource.com/node_8.x">https://deb.nodesource.com/node_8.x</a> xenial main</pre><p>c)<strong> </strong>Download the GPG Signing Key from Nodesource for the repository</p><pre>curl -s <a href="https://deb.nodesource.com/gpgkey/nodesource.gpg.key">https://deb.nodesource.com/gpgkey/nodesource.gpg.key</a> | sudo apt-key add -</pre><p>d) sudo apt-get update</p><p>Just to verify if everything is going well you can check with the following command:</p><p><strong>apt-cache policy nodejs &gt;&gt;&gt;</strong></p><blockquote><em>Version table:<br></em><strong><em>8.2.1-</em></strong><em>1nodesource1~xenial1 500<br>500 https://deb.nodesource.com/node_6.x xenial/main amd64 Packages<br>4.2.6~dfsg-1ubuntu4 500<br>500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages</em></blockquote><p>e) sudo apt-get isntall nodejs</p><p>You will be having an updated version of NodeJs installed in your system</p><pre>$ nodejs — version<br>v8.15.0<a href="https://github.com/litecoin-project/insight-lite-api">https://github.com/litecoin-project/insight-lite-api</a></pre><p>And your nodejs is installed.</p><blockquote>2) Installing Bitcore</blockquote><p>To install the latest version of bitcore ,BTC node version till 0.12.1 is required, let&#39;s download the same</p><pre>sudo npm install -g bitcore  — unsafe-perm=true</pre><p>You might encounter following error</p><blockquote>fatal error: zmq.h: No such file or directory</blockquote><p>For this your need to install libzmq3 in your local machine, which can be done with following command:</p><pre>apt-get install libzmq3-dev</pre><p>Bitcore uses zeromq internally, Now what is Zeromq?</p><p>ZeroMQ is a high-performance asynchronous messaging library, aimed at use in distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ZeroMQ system can run without a dedicated message broker. Click <a href="https://zeromq.org/">here</a> for detail</p><p>After zeromq has been installed in your system, try downloading the bitcore library with the above-mentioned command.</p><blockquote>3) API consumption</blockquote><p>To start the API services, you first need to download bitcoin node in your local machine for that first create a directory where your node will be downloaded and start synchronizing process with the following command :</p><pre>bitcore create mynode_btc<br>cd mynode_btc<br>bitcore start</pre><p>For API details please follow their official <a href="https://github.com/bitpay/bitcore">github</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53c9a6b33bd4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Malware detection using Blockchain Technology]]></title>
            <link>https://medium.com/@parishilanrayamajhi/malware-detection-using-blockchain-technology-bca2a67f5dd?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/bca2a67f5dd</guid>
            <category><![CDATA[quorum]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Sat, 16 Mar 2019 09:37:06 GMT</pubDate>
            <atom:updated>2019-03-16T09:37:06.770Z</atom:updated>
            <content:encoded><![CDATA[<h3>My approach for protection of malwares using Blockchain technology</h3><p>This problem can be resolved with a combination of AI and Blockchain.</p><p><strong>Malware:</strong> <em>software that is specifically designed to disrupt, damage, or gain unauthorized access to a computer system.</em></p><p>The task of malware detection is done with private node following the constellation protocol as provided by quorum and <a href="https://en.wikipedia.org/wiki/Deep_belief_network"><strong><em>deep belief <br>neural network</em></strong></a> (DBN) as the detection engine.</p><p>Our approach is to detect Malware embedded code/file into two classes being affirmative or negative using DBN.</p><h4><strong>Approach:</strong></h4><blockquote>An extensive data set of positive as well as negetive data is used to train the DBN and the dataset set is provided to each node as transactions. The blockchain architecture of <a href="https://github.com/jpmorganchase/quorum"><strong><em>quorum</em></strong></a> is being used to make sure the that no single corrupt node will be able to compromise the network.</blockquote><h4>Procedure</h4><p>Any new file added to a node in the network have detection engine (DBN [trained model]) that helps to detect the malware using deep belief neural network (DBN). <br>The numeric result produced by a engine represents the probability of the file being malicious or not. <br>The numeric probability along with the hash of the file is boradcasted to blockchain and at the same time the copy of the file is being transmitted to each constellation node for respective <br>validation.<br>By this point it has only been broadcasted but not validated by other peer nodes so the file is still not accepted by the network. <br>When other peer node get the transaction in blockcahin, they check if the equivalent file has been received by their constellation node or not. After getting the positive response <br>every constellation node, make the file run through the detection engine. All the nodes possess unique but similar detection engines of their own and they produce their own probability.<br>if the calculated probability is more the the minimum threshold then the file is not mallecious and the respective node accepts the file otherwise they decline the file .<br>Accordingly if maximum node validate the transaction then the file is not mallecious and is included in the network else its is descarded by the entire network.</p><p>This is how you can protect your network from being compromised from possible maleares added in the network by intruders.</p><p><em>This is just a approach from my side. If any one liked my approach and is interested in R&amp;D on this topic feel free to contact me. I would be happy to help you with my knowledge and contribution regarding it.</em></p><p>Regards,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bca2a67f5dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Erc20 time locking explained]]></title>
            <link>https://medium.com/@parishilanrayamajhi/erc20-time-locking-explained-db7fa6fd0166?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/db7fa6fd0166</guid>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[erc20-token]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Mon, 11 Mar 2019 14:52:50 GMT</pubDate>
            <atom:updated>2019-03-13T09:17:08.702Z</atom:updated>
            <content:encoded><![CDATA[<p>Before starting we need to understand the concept of owner of a smart contract.</p><p>The address by which you deploy a contract now becomes a owner address,When you deploy a ERC20 contract you first transfer all of the total supply to owner address in my case it is</p><p><strong><em>owner : </em></strong><em>0xca35b7d915458ef540ade6068dfe2f44e8fa733c</em></p><p><strong><em>code source : </em></strong><a href="https://ethfiddle.com/5WOwwx4u05"><strong><em>https://ethfiddle.com/5WOwwx4u05</em></strong></a></p><h3>1.Total Supply</h3><p>Gives the total supply of the particular ERC20</p><p>initially the total supply is defined to be :</p><blockquote>uint256 private constant totalsupply_ = 1000000000</blockquote><p>When we deployed the contract, we have mentioned in our constructor that</p><blockquote>constructor() public{<br> <br> balanceof_[msg.sender] = totalsupply_;<br> owner = msg.sender;<br> }</blockquote><p>total supply is assigned to the balance of owner address, <br>so at this point(just after deploying a contract) balance of my owner address is 1000000000</p><h3>2. Transfer</h3><blockquote>function transfer(address to_, uint256 value_) external returns (bool){</blockquote><p>This function transfer tokens from one address to another</p><p>ip:</p><p><strong>to_address</strong> → the receiver address (for instance our to_address is : <em>0xdd870fa1b7c4700f2bd7f44238821c26f7392148</em> )</p><p><strong>value</strong> → no of token to be sent</p><p>eg:</p><p>ip parameters:</p><p><em>“0xdd870fa1b7c4700f2bd7f44238821c26f7392148&quot;,10</em></p><p>op:</p><p>true/false</p><h3>3)BalanceOf(address)</h3><p>Function gives the balance of particular address</p><p>earlier balance of to_address(<em>0xdd870fa1b7c4700f2bd7f44238821c26f7392148 )</em>was 0</p><p>now after i called transfer function my balance of to_address(<em>0xdd870fa1b7c4700f2bd7f44238821c26f7392148) address is 10</em></p><h3>4) approve</h3><p>In some cases owner can approve thrid party address to transfer balance from owner’s address to xyz address. For that first of all owner need to assign third party address the right , and he can do so by calling approve function..</p><blockquote><em>function approve(address spender_, uint256 value_) external returns (bool){</em></blockquote><p>here spender_ is the third party address that need to be given rights of owner</p><p>lets say that address is : <em>0x583031d1113ad414f02576bd6afabfb302140225 , </em>and he wants to allow spender to send 5000 coins</p><p>to do so owner need to call approve function with following parameter</p><p>ip: approve(“0x583031d1113ad414f02576bd6afabfb302140225”,5000)</p><p>op: true</p><h3>5) allowance</h3><p>This function validate how many tokens are actually allowed by owner to third_party address so that he can transfer on behalf of owner:</p><p>for eg: in step 4 we assign 5000 tokens as sendable by address : 0x583031d1113ad414f02576bd6afabfb302140225 which we can validate using allowance function</p><p>ip: allowance (“0xca35b7d915458ef540ade6068dfe2f44e8fa733c”,”0x583031d1113ad414f02576bd6afabfb302140225&quot;)</p><p><strong>op: 5000</strong></p><p>here</p><p>0xca35b7d915458ef540ade6068dfe2f44e8fa733c → address of owner</p><p>0x583031d1113ad414f02576bd6afabfb302140225 → address of sender</p><h3>6) transferFrom</h3><p>the use of this function is kind of trikky,</p><p>If you think this is normal function where from and to address is given and by calling this function you can transfer funds from one address to another address then thats wrong. You cannot manipulate balance from other address though you are the contract owner, unless someone approves you by calling <em>approve function(</em>like we did it before<em>)</em></p><p>Now to test this function:</p><p>instead of ower calling the function we should call the function with the third_party address(<em>0x583031d1113ad414f02576bd6afabfb302140225</em>) but and we will transfer funds from owner address to xyz address i.e (<em>0xdd870fa1b7c4700f2bd7f44238821c26f7392148</em>). So lets transfer 4 tokens</p><p>ip:</p><p><em>transferFrom(</em>“0xca35b7d915458ef540ade6068dfe2f44e8fa733c”,”0xdd870fa1b7c4700f2bd7f44238821c26f7392148”,4<em>)</em></p><p>op: true</p><p>** point to remember: we have allowed third party address 5000 tokens to transfer but here he only sent 4 token, so now if you check allowance then 5000–4 = 4996 tokens(he can tranfer to other address as well as his own address)</p><p>This is how a ERC20 works.</p><p>Now after having clear understanding about ERC20, we can move ahead to undersatand how the concept of locking is achived in smart contracts.</p><h3>7) lock_erc(value,releasetime)</h3><p>Only owner can use this functionality i.e in ower case if any other address invoke this function other than 0<em>xca35b7d915458ef540ade6068dfe2f44e8fa733c </em>then that will throw exception</p><p>to envoke this functionality you need to call lock_erc function with following ip:</p><p>a) total tokens you want to lock</p><p>b) total time in epoch you want to lock the contract till</p><p><em>you can convert date time to epoch time anytime using : </em><a href="https://www.epochconverter.com/"><em>https://www.epochconverter.com/</em></a></p><p>lets say i want to lock <strong>5000</strong> tokens till <strong>1552315106(</strong>this is the date time of today<strong>)</strong></p><p>then i will envoke function like:</p><blockquote><em>ip: lock_erc(5000,1552315106</em>)</blockquote><blockquote>op: index (1,2,3….)</blockquote><p>now after response is some integer, 5000 tokens has been locked, and if you check the balance of owner it is reduced by 5000.</p><p>lets say we locked output of above <em>lock_erc(5000,1552315106</em>) is 1</p><p>i.e in 1 index 5000 tokens are locked till epoch time <em>1552315106</em></p><ul><li>*imp point: The index no that is returned by the function lock_erc is very crucial to release the token, while releasing the locked tokens you need to pass the index no where you initially locked the n no of tokens</li></ul><h3>8)release_erc(index_no)</h3><p>to release erc all you need to remember is the index no that is returned when we invoked lock_erc() function, that mens you tokens are locked on particular indexes .</p><p>if the op of <em>lock_erc(5000,1552315106</em>) was 1</p><p>then our current ip would be:</p><blockquote>release_erc(1)</blockquote><blockquote>op: true / false</blockquote><p>if its true: if the release time satisfy the condition then automatically 5000 tokens would be allocated to owners address i.e <em>0xca35b7d915458ef540ade6068dfe2f44e8fa733c in our case.</em></p><p>and if you check the balance of owner now it will show incresed balance by 5000</p><p>thanks all!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db7fa6fd0166" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[litecore setup: ubuntu 16.04]]></title>
            <link>https://medium.com/@parishilanrayamajhi/litecore-setup-ubuntu-16-04-6412ded78a60?source=rss-87165d5a1c88------2</link>
            <guid isPermaLink="false">https://medium.com/p/6412ded78a60</guid>
            <category><![CDATA[bitcoind]]></category>
            <category><![CDATA[litecoind]]></category>
            <category><![CDATA[litecore]]></category>
            <category><![CDATA[bitpay]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Parishilan Rayamajhi]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 10:24:38 GMT</pubDate>
            <atom:updated>2020-04-15T06:42:39.035Z</atom:updated>
            <content:encoded><![CDATA[<h3>Litecoin Application: litecore setup</h3><h3>What is Litecore and what is it used for?</h3><p>Litecore is a SAAS infrastructure that helps us to create Litecoin based application , allowing us to easily interact with Litecoin Blockchain. Litecore comes with a package allowing us to easily setup Litecoin full node and provides APIs to interact with it. Here is the list of the functionality provided by litecore:</p><ol><li>Litecoin wallet service (client and server)</li><li>Litecoin explorer</li><li>Full node setup</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_Vfe_n5iwmhikEwdlTD3A.png" /><figcaption>Litecore Architecture</figcaption></figure><p><strong>Lets start with the setting up Litecore in Ubuntu 16.04</strong></p><blockquote>1) Installing Nodejs v&gt;8.x</blockquote><p>Installing/Upgrading</p><p>There are soo many ways to deal with it, I will be guiding for the simplest one</p><p>a) Create nodesource.list</p><pre>sudo vim /etc/apt/sources.list.d/nodesource.list</pre><p>b) Add following lines(you can replace 8.x with whichever version of Nodejs you want to install)</p><pre>deb <a href="https://deb.nodesource.com/node_8.x">https://deb.nodesource.com/node_8.x</a> xenial main<br>deb-src <a href="https://deb.nodesource.com/node_8.x">https://deb.nodesource.com/node_8.x</a> xenial main</pre><p>c)<strong> </strong>Download the GPG Signing Key from Nodesource for the repository</p><pre>curl -s <a href="https://deb.nodesource.com/gpgkey/nodesource.gpg.key">https://deb.nodesource.com/gpgkey/nodesource.gpg.key</a> | sudo apt-key add -</pre><p>d) sudo apt-get update</p><p>Just to verify if everything is going well you can check with the following command:</p><p><strong>apt-cache policy nodejs &gt;&gt;&gt;</strong></p><blockquote>Version table:<br> <strong>8.2.1-</strong>1nodesource1~xenial1 500<br> 500 https://deb.nodesource.com/node_6.x xenial/main amd64 Packages<br> 4.2.6~dfsg-1ubuntu4 500<br> 500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages</blockquote><p>e) sudo apt-get isntall nodejs</p><p>You will be having an updated version of NodeJs installed in your system</p><pre>$ nodejs — version<br>v8.15.0<a href="https://github.com/litecoin-project/insight-lite-api">https://github.com/litecoin-project/insight-lite-api</a></pre><p>And your nodejs is ready to go !!!</p><blockquote>2) litecore setup</blockquote><p>a) install litecore library</p><pre>sudo npm install -g litecore-node — unsafe-perm=true</pre><h4><strong>After successful installation create a directory to store litcoin fullnode for now lets say its mynode_ltc</strong></h4><pre>litecore-node create mynode_ltc<br>cd mynode_ltc</pre><p>Now its time to start synching litcoin node, which can be done with command:</p><pre>litecore-node start</pre><p>If everything going ok then you will see similar logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*npW8_TSSXtdKziHg0TFLkg.png" /></figure><p>After the node synchronizes completely, APIs are ready to use, to see list of APIs available reference Github link is attached below:</p><ul><li><a href="https://libraries.io/npm/litecore-node">litecore-node on NPM</a></li><li><a href="https://github.com/litecoin-project/litecore">litecoin-project/litecore</a></li><li><a href="https://github.com/litecoin-project/insight-lite-api">litecoin-project/insight-lite-api</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6412ded78a60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>