<?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 Shih-Yu Hwang on Medium]]></title>
        <description><![CDATA[Stories by Shih-Yu Hwang on Medium]]></description>
        <link>https://medium.com/@shihyuhwang?source=rss-8daf9fad9874------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AZDlYYJsBzkYW8QDiLTZcg.jpeg</url>
            <title>Stories by Shih-Yu Hwang on Medium</title>
            <link>https://medium.com/@shihyuhwang?source=rss-8daf9fad9874------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:19:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shihyuhwang/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[Export to IPFS with Livepeer Video Services]]></title>
            <link>https://medium.com/@shihyuhwang/export-to-ipfs-with-livepeer-video-services-861df54cc5b2?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/861df54cc5b2</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[ipfs]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Mon, 02 May 2022 21:31:01 GMT</pubDate>
            <atom:updated>2022-05-02T21:31:01.657Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uxNtJB25U5CohOwn" /><figcaption>Photo by <a href="https://unsplash.com/@spacex?utm_source=medium&amp;utm_medium=referral">SpaceX</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Where to store NFTs (non-fungible tokens) is just as important as what type of NFTs to create. In the process of making them, storage is an essential part of it as it allows the NFTs to be preserved.</p><p><a href="https://ipfs.io/">IPFS</a>, short for Interplanetary File System, has been around for a while, which means its network has had time to mature and be reliable. Their protocol is used by the majority of projects that utilize decentralized storage, including NFTs. By exporting assets to IPFS, not only will they generate a unique fingerprint called content identifier (CID) for the NFTs, but also this data will be preserved due to the support of their community for maintaining and expanding their decentralized ecosystem.</p><p>Livepeer Video Services makes the process of exporting to IPFS easy by using the <a href="https://livepeer.com/docs/api-reference/vod">Video on Demand (VoD) API</a>. With a simple step, assets that get uploaded to Livepeer Video Services will have the option to be exported to IPFS. Once the asset has been exported they are ready to be minted. This reduces the process of transcoding the assets and then taking that transcoded asset from Livepeer VIdeo Services and then using IPFS.</p><p>In this tutorial, we will look at the ease of using the VoD API to upload assets to LVS and then export them to IPFS.</p><p>Access to a free Postman and Livepeer Video Services account is required. Visit <a href="https://livepeer.com/blog/how-to-make-api-calls-with-postman-and-livepeer-video-services">How to make API calls with Postman and LVS</a> tutorial for instructions on getting set up.</p><h4><strong>Step 1</strong></h4><p>There are two ways to provide Livepeer with assets for VoD, either importing or uploading the asset. The following steps address how to implement both.</p><h4><strong>Step 1A:</strong> Import an asset</h4><p>To import an asset from an external URL, select the <strong>POST</strong> option and paste in Livepeer’s base URL for importing an asset <strong><em>https://livepeer.com/api/asset/import</em></strong></p><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*1FjWZrCBoNmrxzw8" /></figure><ul><li>Then underneath the URL, click on the Authorization tab, and select Bearer Token as the type</li><li>Copy and paste your API key from Livepeer Video Services</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*Lcmz5npC8NhMcnkN" /></figure><ul><li>Select the Body tab and underneath it select the raw radio button</li><li>Click the Text drop-down menu and select the JSON option</li><li>In the text box field below, paste the following code which is from the <a href="https://livepeer.com/docs/api-reference/vod/import">API reference</a>. You can change the <strong>name </strong>to whatever you want as this is for the name of your stream and the<strong> URL</strong> is the URL file of your asset</li></ul><pre>{“url”: ”https://www.pexels.com/video/5613843/download/”,</pre><pre>“name”: “JellyFish”<br>}</pre><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*s2e0yQcbNSXegWIF" /></figure><ul><li>Click the code icon <strong>&lt; &gt;</strong> on the right side menu to confirm the format is the same as the cURL example in the API reference</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*acoqDODweg7qBBtZ" /></figure><ul><li>Now click the <strong>Send</strong> button and you should receive a confirmation that it went through with a 201 status</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*iz_VM5WaGuP_cEnD" /></figure><h4><strong>Step 1B:</strong> Upload an asset</h4><p>This is a two-step process that allows the user to provide the asset by directly uploading to Livepeer Video Services.</p><h4><strong>Step 1B-1 — </strong>Create URL for direct upload</h4><ul><li>Select the <strong>POST</strong> option and paste in Livepeer Video Services’ URL for importing an asset <strong>https://livepeer.com/api/asset/request-upload</strong></li><li>Then underneath the URL, click on the <strong>Authorization </strong>tab, and select <strong>Bearer Token</strong> as the type</li><li>Copy and paste your API key from Livepeer Video Services</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*6IVG6NsiwN94Qege" /></figure><ul><li>In the text box field below, paste the following code which is from the <a href="https://livepeer.com/docs/api-reference/vod/import">API Reference</a>. You can change the name to whatever you want as this is for the name of your stream.</li></ul><pre>{</pre><pre>“name”: “JellyFish”</pre><pre>}</pre><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*IO6bBSRu2p4VIlqc" /></figure><ul><li>Click the code icon <strong>&lt; &gt;</strong> on the right side menu to confirm the format is the same as the cURL example in the API reference</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*i6zgB_BvqhwSWDKQ" /></figure><ul><li>Click the blue send button and you should get back a 200 status with the response including the parameters of the stream</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*iTCC_vKgh0ayFp1t" /></figure><p>Now that the URL for direct upload is created, time to upload the content.</p><p><em>*Copy the URL and the ID of the asset/task from the response for the next part.</em></p><h4><strong>Step 1B-2 </strong>— Upload the contents</h4><ul><li>Replace <strong>POST</strong> with <strong>PUT</strong> and insert the <strong>URL</strong> from the response in the previous step. It should look similar to the following:</li></ul><pre><a href="https://origin.livepeer.com/api/asset/upload">https://origin.livepeer.com/api/asset/upload</a></pre><pre>/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9</pre><pre>.eyJwcmVzaWduZWRVcmwiOiJodHRwczovL3N0b3JhZ2UuZ29vZ2xlYXBpcy5jb20vbHAtdXMtd</pre><pre>m9kLWNvbS9kaXJlY3RVcGxvYWQvZWIyMG01cDdqd3d1bDZ3OS9zb3VyY2U_WC1BbXotQWxnb3J</pre><pre>pdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ29udGVudC1TaGEyNTY9VU5TSUdORUQtUEFZT</pre><pre>E9BRCZYLUFtei1DcmVkZW50aWFsPUdPT0cxRVlVTldOVjZSWUlLNTQySFdBM1JMN1JCN0pVT0V</pre><pre>RM1lMMjNRWUI2Q0hQRzVITzJRQzMzTUpWVVklMkYyMDIyMDQyMSUyRnVzJTJGczMlMkZhd3M0X</pre><pre>3JlcXVlc3QmWC1BbXotRGF0ZT0yMDIyMDQyMVQxNDM1NTNaJlgtQW16LUV4cGlyZXM9OTAwJlg</pre><pre>tQW16LVNpZ25hdHVyZT1iZGZhOGNlYWVkNDg2YWIyMzYyZmJkMzA0MGRlNjA4MjM0ZmQ0YWU0O</pre><pre>DIyYTE4NzBmMzhiZTRiMDFiZmZhZWE1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ4LWlkPVB</pre><pre>1dE9iamVjdCIsImF1ZCI6Imh0dHBzOi8vbGl2ZXBlZXIuY29tIiwiaWF0IjoxNjUwNTUxNzUzf</pre><pre>Q.ujURa40V95ETrUrjYi4Ho5vD3g5–5l_5o0kJfJNUMiA</pre><ul><li>Select the Headers tab and for the<strong> Key </strong>select <strong>Content-Type</strong> and the <strong>Value</strong> select <strong>video/mp4</strong></li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*EkGO0eOddDcnFPdW" /></figure><ul><li>Under the body tab, select the binary radio button</li><li>Then select the video file you want to upload</li></ul><p><em>*Notice that we only support mp4 files encoded with H264 video and AAC audio for now. If you are unsure about these, try sending the file anyway and check any returned errors!</em></p><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*_VTnJAQ5MZN1GDty" /></figure><ul><li>Click the code icon <strong>&lt; &gt;</strong> on the right side menu to confirm the format is the same as the cURL example in the API reference</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*Y8SYumf71Y1UqkqO" /></figure><ul><li>Click the blue send button and you should get back a 200 status with the response including the parameters of the stream</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*TOZAifXbGxJ39w9l" /></figure><h4><strong>Step 2:</strong> Retrieve an asset</h4><p>We need to check to make sure that the asset is ready before exporting it since it can take some time to upload.</p><p>For the asset ID here, use the <strong>asset.id</strong> field in the response to the <strong>Import</strong> or <strong>Request Upload</strong> requests above.</p><ul><li>Retrieve an individual asset, select <strong>GET</strong> option, and then paste in Livepeer’s URL for retrieving an asset <strong>https://livepeer.com/api/asset/:assetId</strong></li><li>In the params tab, paste in the asset ID in the <strong>Value</strong> column associated with the <strong>Key: assetId</strong></li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*cy9WqATNgqb3zjNy" /></figure><ul><li>Make sure the <strong>Body </strong>tag has the <strong>none</strong> radio button selected</li><li>Click the blue send button and you should get back a 200 status with the response including a list of the assets</li><li>Look for the <strong>status</strong> in the response body, it should return <em>status:“ready”</em>. If it is <em>status:“waiting”</em>, then wait a little longer and repeat this step until the status is <strong>ready</strong> before moving to the exporting step.</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*pRIxnbp-bxEWH6I9" /></figure><h4><strong>Step 3: Export to IPFS</strong></h4><ul><li>Select the <strong>POST</strong> option and paste in Livepeer’s URL for exporting an asset to IPFS<strong> https://livepeer.com/api/asset/$ASSET_ID/export</strong></li></ul><p><em>*The</em><strong><em> $ASSET_ID</em></strong><em> is located in the response body from step 1A or 1B depending on the method you chose.</em></p><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*7NCarJnsvWEmz12Z" /></figure><ul><li>Make sure the <strong>Body</strong> tag has the <strong>raw</strong> radio button selected and the <strong>JSON</strong> format is selected from the drop-down menu on the right</li><li>In the text box field below, paste the following code from the <a href="https://livepeer.com/docs/api-reference/vod/export">Livepeer’s VoD API Reference</a></li></ul><pre>{ “ipfs”: { } }</pre><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*PcSUzguLNaPYw1d3" /></figure><ul><li>Click the code icon <strong>&lt; &gt;</strong> on the right side menu to confirm the format is the same as the cURL example in the API reference</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*6InbNuUmv4Z0mDsa" /></figure><ul><li>Click the blue send button and you should get back a 201 status with the response showing the task has been created with the type <strong>export</strong></li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*N4-P1nMuBz9gYlM1" /></figure><p><em>*IPFS is a complex protocol and so the export task can take a while. Expect this to take a bit longer than the import task</em></p><p><em>*Copy the </em><strong><em>ID</em></strong><em> of the task from the response for the next part.</em></p><h4>Step 4 Retrieve a task</h4><p>For the task ID here, use the <strong>task.id</strong> field in the response of the <strong>Export</strong> request above.</p><ul><li>Select the <strong>GET</strong> option and paste in Livepeer’s URL for retrieving a specific task with the task id <strong>https://livepeer.com/api/task/:taskId</strong></li><li>In the params tab, paste in the task ID in the <strong>Value</strong> column associated with the <strong>Key: taskId</strong></li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*XqXY9a5-PqzLmCJT" /></figure><ul><li>Make sure the <strong>Body</strong> tag has the <strong>none</strong> radio button selected</li><li>Click the blue send button and you should get back a 200 status with the response including the specific task requested</li></ul><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*iJhTik_juDuU5RzU" /></figure><h4>Getting the CID</h4><p>IPFS locates the content based on what is inside of it rather than by the location, CID is what allows it to do this.</p><p>To Get the CID and metadata URL for the asset that was just exported, you can get it by retrieving the task above until it is finished (check the <strong>status </strong>field in the response). That finished task will have an output with all the information about that asset, and the CID information is located under the <em>output.export.ipfs</em> path.</p><p>See the image below:</p><figure><img alt="Postman Dashboard" src="https://cdn-images-1.medium.com/max/600/0*5yZKAaxCAh4J-VXh" /></figure><p>As you can see here, information such as the video file’s CID, location of the URL on IPFS, and other metadata information.</p><h4>Conclusion</h4><p>With the ability to upload assets and export them to IPFS easily with <a href="https://livepeer.com/docs/api-reference/vod">Livepeer Video Services’ VoD API</a>, those assets can now be stored in decentralized storage and be accessible.</p><p>Start creating your own VoD Dapps and store them in decentralized storage.</p><p>Take it to the next level by minting video NFTs using Livepeer Video Services video NFT SDK.</p><p><a href="https://livepeer.com/docs/guides/video-nfts/mint-a-video-nft"><strong>Mint Video NFTs</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=861df54cc5b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to mint a video NFT using Livepeer Video Services + Polygon]]></title>
            <link>https://medium.com/@shihyuhwang/how-to-mint-a-video-nft-using-livepeer-video-services-polygon-431d4ad88c2d?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/431d4ad88c2d</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[polygon]]></category>
            <category><![CDATA[nft]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Mon, 11 Apr 2022 21:27:34 GMT</pubDate>
            <atom:updated>2022-04-13T20:44:30.351Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Picutre of colorful leaves" src="https://cdn-images-1.medium.com/max/1024/0*yogBb-6QGcS-wW2N" /><figcaption>Photo by <a href="https://unsplash.com/@jeremythomasphoto?utm_source=medium&amp;utm_medium=referral">Jeremy Thomas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The concept of NFTs has been around since the 2014s but it wasn’t until 2017 that projects like <a href="https://www.cryptokitties.co/">CryptoKitties</a> and <a href="https://www.larvalabs.com/cryptopunks">CryptoPunks</a> started to create traction for NFTs. Jumping to 2021, NFTs took off like wildfire. They started being referenced in pop culture, mainstream media, and they influenced the concepts that many hackathon projects were based on.</p><p>The technology for creating NFTs has come a long way and is now more accessible to developers and non-developers alike. Along with the creation of NFT marketplaces such as <a href="https://opensea.io/">OpenSea </a>and <a href="https://rarible.com/">Rarible</a>, anyone can mint their own NFTs and sell them.</p><p>When minting video NFTs, a major factor to consider is the file size. Livepeer Video Services solves this issue when using the <a href="https://www.npmjs.com/package/@livepeer/video-nft">Video NFT SDK</a>. This SDK will transcode the video to the proper file size utilizing the <a href="https://livepeer.org/">Livepeer Network</a> as well as leveraging the layer 2 solutions of <a href="https://polygon.technology/">Polygon</a> to reduce the cost of transactions on the Ethereum blockchain. Using the SDK makes it easy and more affordable to create video NFTs.</p><p>In this tutorial, we will utilize Livepeer Video Services’ <a href="https://github.com/livepeer/video-nft">Mint a Video NFT</a> tool to create our own NFT that can play a video.</p><p>Before we get started, here is a checklist of items required for this tutorial. Instructions on how to get and install these items will be provided in the steps that follow.</p><p><strong>Checklist</strong></p><p>☑️ Sign up for a free account at <a href="https://livepeer.com/register">Livepeer Video Services</a> to create an API key</p><p>☑️ <a href="https://www.pexels.com/video/group-of-jellyfish-swimming-underwater-5613843/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Jellyfish Video</a></p><blockquote>*This is an example video that will be used, there are other free videos available at <a href="https://www.pexels.com/videos/">Pexels</a>.</blockquote><p>☑️ Sign up for a free <a href="https://metamask.io/">Metamask</a> account</p><p>☑️ Add Polygon Mumbai testnet to Metamask wallet</p><p>☑️ Get Polygon test <a href="https://faucet.polygon.technology/">MATIC</a></p><p>☑️ Install <a href="https://www.npmjs.com/package/@livepeer/video-nft">Video NFT SDK</a></p><h3>Installation process</h3><p><strong>Step 1: </strong>Signup for a free account at <a href="https://livepeer.com/">Livepeer Video Services</a> and create an API key</p><blockquote><em>* If you need a step-by-step process for getting a free account and the API key, visit the</em><a href="https://livepeer.com/blog/how-to-make-api-calls-with-postman-and-livepeer-video-services"><em> How to make API calls with Postman</em></a><em> tutorial</em><strong><em>.</em></strong></blockquote><p><strong>Step 2: </strong>Get a video to mint as an NFT</p><p>For this example, we will use this video: <a href="https://www.pexels.com/video/group-of-jellyfish-swimming-underwater-5613843/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Jellyfish Video</a></p><blockquote><em>*You can also find another video using </em><a href="https://www.pexels.com/videos/"><em>Pexels</em></a><em> or use provide one of your own. If you do use one of your own, make sure it is in a .mp4 format.</em></blockquote><p><strong>Step 3: </strong>Install Metamask (if you do not already have one)</p><ul><li>Go to <a href="https://metamask.io/download/">Metamask</a> and download the browser extension. For this tutorial, we will use the Chrome version, but a Firefox version is also available.</li></ul><figure><img alt="Metamask Website" src="https://cdn-images-1.medium.com/max/1024/1*SJ0PWZf0gW_GdrPxrOgsyQ.png" /></figure><figure><img alt="Metamask Website" src="https://cdn-images-1.medium.com/max/1024/1*Gpoen65Wv-rlDPP-j-Qigg.png" /></figure><ul><li>Once downloaded, you should see the Metamask logo in the extension menu</li></ul><figure><img alt="Metamask Website" src="https://cdn-images-1.medium.com/max/1024/1*wAGfyMjGYatKDTR9hWOnrA.png" /></figure><ul><li>Next, set up your Metamask wallet — <a href="https://docs.polygon.technology/docs/develop/metamask/hello/">Polygon</a> has a great tutorial on how to do this</li></ul><p><strong>Step 4: </strong>Configuring Polygon network for Metamask</p><ul><li>We need to configure the Polygon network to the Metamask wallet. For this tutorial, we will use the Polygon testnet called <a href="https://docs.polygon.technology/docs/develop/metamask/config-polygon-on-metamask">Mumbai</a>, but they also have the <a href="https://docs.polygon.technology/docs/develop/metamask/config-polygon-on-metamask">Polygon mainnet</a> configuration as well.</li></ul><p><strong>Step 5: </strong>Getting MATIC for testing</p><p>Minting NFTs has a gas fee associated with it, so we need to add funds to our wallet. Since we are using the Mumbai testnet, we will need to get some <a href="https://faucet.polygon.technology/">test MATIC tokens</a>. If you are using Polygon’s mainnet, you can find the <a href="https://matic.supply/">MATIC faucet</a> here.</p><figure><img alt="Polygon website" src="https://cdn-images-1.medium.com/max/1024/1*2D4KG9DOTrCWiNv0Fetg9w.png" /></figure><ul><li>Make sure the Mumbai tab is selected</li><li>Paste in your wallet address and you should receive some test MATIC token</li></ul><figure><img alt="Polygon website" src="https://cdn-images-1.medium.com/max/1024/1*pt8SZtFhwIg8wkAHBkDY1w.png" /></figure><ul><li>Click the submit button and a confirmation window should pop up</li></ul><figure><img alt="Polygon website" src="https://cdn-images-1.medium.com/max/1024/1*jgZ7NzmwTLbUB_n_a8YkPw.png" /></figure><ul><li>Click confirm and a message should appear stating the transaction went through</li></ul><figure><img alt="Polygon website" src="https://cdn-images-1.medium.com/max/1024/1*ZvbslZsoTTxkDfU5YDZm1A.png" /></figure><ul><li>Your wallet should be funded with some test MATIC tokens</li></ul><figure><img alt="Polygon website" src="https://cdn-images-1.medium.com/max/1024/1*2VZ9IozchG7R7kSwMyB5aQ.png" /></figure><p><strong>Step 6: </strong>Installing the mint Video-NFT</p><p>*If you want to have video-nft available as a command on your machine, you can also install the CLI persistently with <strong><em>npm i -g @livepeer/video-nft</em>,</strong> and after that just call video-nft from anywhere to run it.</p><p>Create a new directory with the command</p><pre><em>mkdir VideoNFT </em></pre><figure><img alt="Terminal window" src="https://cdn-images-1.medium.com/max/1024/1*K40YcejADZkB7L8q18NwBQ.png" /></figure><p>Change into that directory using</p><pre><em>cd VideoNFT </em></pre><figure><img alt="Terminal window" src="https://cdn-images-1.medium.com/max/1024/1*PS1bS5tDCJ0zrKUcGmB8CQ.png" /></figure><ul><li>Move the video from <strong>Step 2 </strong>into this directory</li><li>The file should be in this directory, use the ls<em> </em>command to view it</li></ul><pre>ls</pre><figure><img alt="Terminal window" src="https://cdn-images-1.medium.com/max/1024/1*ppbP4pADzatCSiOL-f1cSA.png" /></figure><ul><li>Run Livepeer Video Services Video NFT using</li></ul><pre><em>npx @livepeer/video-nft</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c4ic3Mj4CeMMgsq-qDXbRQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2VQ1aImGR-0aQLrPofwaA.png" /></figure><ul><li>Copy and paste the API key that you got from <strong>Step 1</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1f_4tzHgh2_fbD_xoWFVw.png" /></figure><ul><li>Type in the name of the video file, for this example, it is<em> jellyfish.mp4</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jvwILZB8yCqm8cmez9pphw.png" /></figure><ul><li>Provide the name you want to give the NFT, you can use the file name to name the NFT but in this example, we will use <em>JellyFish</em></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPJutCsZe9xZaJX5g24mvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3aw2_r4ah57tZH2RTDQzQ.png" /></figure><ul><li>A message should appear that states the export is successful along with the metadata and our URL for minting</li></ul><figure><img alt="Terminal window" src="https://cdn-images-1.medium.com/max/1024/1*Crx4Lvs-kGQ_XuBF53qcaA.png" /></figure><ul><li>Copy the URL in <strong>Step</strong> <strong>3</strong> for the next step</li></ul><p><strong>Step 7: </strong>Minting the video NFT</p><ul><li>Copy and paste the URL from the previous step into a browser window</li><li>A Livepeer Video Services site should appear with a Mint a Video NFT pop up</li></ul><figure><img alt="LVS mint NFT dashboard" src="https://cdn-images-1.medium.com/max/1024/1*NbdZ_59-ULQQwl0rnzmkhA.png" /></figure><ul><li>Click the <strong>Connect to Metamask </strong>button</li><li>Metamask browser extension should open and ask the account to connect to</li><li>Select the account with the funded testnet MATIC and connect it</li></ul><figure><img alt="Metamask wallet extension" src="https://cdn-images-1.medium.com/max/510/1*JjaaCL30N5Bb3qEJ3q_oyQ.png" /></figure><ul><li>Once connected, the pop up should have the <strong>ContractAddress </strong>and the message box should state that you are connected to the Polygon Testnet</li></ul><figure><img alt="LVS mint NFT dashboard" src="https://cdn-images-1.medium.com/max/1024/1*TX7VLkI5niQ4mVWIAK4xXQ.png" /></figure><ul><li>Click the <strong>Mint NFT</strong> button</li></ul><figure><img alt="LVS mint NFT dashboard" src="https://cdn-images-1.medium.com/max/1024/1*fmWw6dKmacvEuTzVFi8l6g.png" /></figure><ul><li>Metamask browser extension should open and ask to confirm the transaction fee</li></ul><figure><img alt="Metamask wallet extension" src="https://cdn-images-1.medium.com/max/438/1*wP_czW9wbdnwWLwe8u8XLw.png" /></figure><ul><li>Click the <strong>Confirm</strong> button</li><li>You should see the minting in progress in the message field</li></ul><figure><img alt="LVS mint NFT dashboard" src="https://cdn-images-1.medium.com/max/1024/1*BvrvWYttYHEaRiuVS1by-Q.png" /></figure><ul><li>Once the minting is completed, it should provide a link to OpenSea testnet where you can view your Video NFT! For example:</li></ul><blockquote><a href="https://testnets.opensea.io/assets/mumbai/0xA4E1d8FE768d471B048F9d73ff90ED8fcCC03643/56"><em>https://testnets.opensea.io/assets/mumbai/0xA4E1d8FE768d471B048F9d73ff90ED8fcCC03643/56</em></a></blockquote><figure><img alt="LVS mint NFT dashboard" src="https://cdn-images-1.medium.com/max/1024/1*gVK-cOK10M7M6mpR-abEuQ.png" /></figure><figure><img alt="Minted NFT on OpenSea testnet" src="https://cdn-images-1.medium.com/max/1024/1*d3qhOeOOE6ut9jraQCFfTw.png" /></figure><p>Congratulations! You have minted a video NFT using Livepeer Video Services <a href="https://livepeer.com/docs/guides/video-nft">Video NFT</a>.</p><p>Using the Video NFT is a great way to get started with being able to upload video NFTs. If you want to upload videos and do not want to mint NFTS, Livepeer Video Services also has Video on Demand where you can do just that.</p><p><a href="https://livepeer.com/docs/api-reference/vod">Check out Video On Demand</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=431d4ad88c2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make API calls with Postman and Livepeer Video Services]]></title>
            <link>https://medium.com/@shihyuhwang/how-to-make-api-calls-with-postman-and-livepeer-video-services-d402b52b3c7d?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/d402b52b3c7d</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[live-streaming]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 21:17:20 GMT</pubDate>
            <atom:updated>2022-03-15T22:04:38.096Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Pink telephone" src="https://cdn-images-1.medium.com/max/1024/0*dcqZT2TcxlYGM78o" /><figcaption>Photo by <a href="https://unsplash.com/@anniespratt?utm_source=medium&amp;utm_medium=referral">Annie Spratt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>APIs are essential when it comes to software development. It allows softwares to communicate with each other to exchange information. In the beginning, when learning to make API calls, it can be a challenge using tools such as cURL in the terminal, <strong>FETCH </strong>in the frontend or backend option such as <strong>Express</strong>. Postman is a great tool for understanding the process of making API calls and getting feedback on the response of those calls. It provides a visual interface and allows developers to get a sense of the workflow which can provide easier transitions to using other tools such as cURL or Express.</p><p>In this tutorial, we will be using <a href="https://www.postman.com/">Postman</a> to make API requests to <a href="https://livepeer.com/">Livepeer Video Services</a> to get a better understanding on building an application similar to Twitch or YouTube. The Livepeer Video Services API consists of the standard features for users such as creating new live streams, recording the streams and getting a list of their streams. By leveraging <a href="https://livepeer.org/">Livepeer’s decentralized network</a> for transcoding, it will be easier and cost effective to scale for in the future.</p><p><strong>Step 1: </strong>Get access to Postman</p><ul><li>Go to <a href="https://www.postman.com/">Postman’s website</a> and sign up for a free account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NoulNFe0cK2tZZCiYnScRQ.png" /></figure><ul><li>You can use their web browser tool or download the desktop version. For this tutorial, we will use the desktop version with <a href="https://www.postman.com/downloads/">Mac OS</a>, but it is also available for <a href="https://dl.pstmn.io/download/latest/win64">Windows</a> and <a href="https://dl.pstmn.io/download/latest/linux64">Linux</a>.</li></ul><p><strong>Step 2: </strong>Get access to Livepeer Video Services</p><ul><li>Go to <a href="https://livepeer.com/">Livepeer Video Services</a> and sign up for a free account.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUGSYClQsoNz4dCPCn0yQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRdZfmUnSV2uM7CvCOqqnA.png" /></figure><p>Now that we have access to these two services, let’s start interacting with them.</p><p><strong>Step 3: </strong>Get an API key</p><ul><li>In your Livepeer dashboard, tap the developers tab and select API keys</li><li>Click the button that says <strong>Create Key</strong></li><li>Then give your key a name and click <strong>Create</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*io2GVZA3QgDslFXtpCJSCw.png" /></figure><figure><img alt="Livepeer Video Services create API key page" src="https://cdn-images-1.medium.com/max/1024/1*sFChsVI5_zjHdQrWv892hA.png" /></figure><p>With the API key, we will start going through the<strong> Stream </strong>section of Livepeer Video Services’ <a href="https://livepeer.com/docs/api-reference/stream/post-stream">API Reference</a>. The reference uses the cURL command but we will do this using Postman instead.</p><p>To learn more about streaming Livepeer Video Services with the cURL command, visit the tutorial <a href="https://livepeer.com/blog/streaming-with-rtmp-api">How To Stream With Livepeer Video Service’s RTMP API</a></p><p><strong>Step 4: </strong>Launch the Postman desktop app</p><ul><li>Click the <strong>+</strong> icon under the Reports tab to start a new request or select <strong>New Tab</strong> under the file menu</li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*tuxYO1-6bl7obrGbJlk37Q.png" /></figure><p><strong>Step 5: </strong>Create a stream</p><p>Select the <strong>POST</strong> option and the paste in Livepeer Video Services’ base URL for streaming<strong> </strong><a href="https://livepeer.com/api/stream"><strong>https://livepeer.com/api/stream</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7pbCCfWVsWyvG3RmDLegtA.png" /></figure><ul><li>Then underneath the URL, click on the <strong>Authorization</strong> tab, and select <strong>Bearer Token</strong> as the type</li><li>Copy and paste your API key from Livepeer Video Services</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sytpNu1KgZ3P-AOSh7Lz3Q.png" /></figure><ul><li>Now select the <strong>Body </strong>tab and then underneath select the <strong>raw</strong> radio button</li><li>Then click the the <strong>Text</strong> drop down menu and select the <strong>JSON</strong> option</li><li>In the text box field below, paste the following code which is from the <a href="https://livepeer.com/docs/api-reference/stream/post-stream">Livepeer Video Services API reference docs</a>. You can change the <strong>name</strong> to whatever you want as this is for the name of your stream</li></ul><figure><img alt="Code for creating stream" src="https://cdn-images-1.medium.com/max/522/1*0F_fOf0EZKAu-3AnksIXMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vD4wFq7ImEuO-RAAf8CKwg.png" /></figure><ul><li>Now click on the <strong>Send</strong> button and you should receive a confirmation that it went through with a 201 status</li><li>Scroll down in the response and copy the <em>id</em> for the stream that was just created. It should be under <em>renditions</em></li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*miRVXukQMdNFTCS6ARjoKQ.png" /></figure><ul><li>Check the Livepeer Video Services’ dashboard and the stream that you just created should come up</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjHBpaU9gxF5fvjtk1SgMg.png" /></figure><p>Now let’s get the stream we just created</p><p><strong>Step 6: </strong>Retrieve a stream</p><ul><li>In the Postman app, we will change from <strong>POST </strong>to <strong>GET</strong>, and in the URL paste in <a href="https://livepeer.com/api/stream/%7Bid%7D"><strong>https://livepeer.com/api/stream/{id}</strong></a> and replace <strong>{id}</strong> with the id we copied from our response earlier.</li><li>Click the blue send button and you should get back a 200 status with the response including the parameters of the stream</li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*B63dY15KsxzYFQUf2RPpXg.png" /></figure><p><strong>Step 7: </strong>Get a list of streams</p><ul><li>In order to get a list of streams, follow <strong>Step 5 </strong>to create a second stream so that there is more than one stream</li><li>Give it a name of your choice, but for this example, it will be named<em> Second Stream</em></li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*ns58zUxHZb36ZS1X--ZxcQ.png" /></figure><ul><li>Go back to Livepeer Video Services’ dashboard and you should see the <strong>Second Stream</strong> appear</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LM1s98UGSH733qvU-3tbpA.png" /></figure><ul><li>Now that we have multiple streams, go back to the Postman app and retrieve them</li><li>Similar to <strong>Step 6</strong> we are changing <strong>POST</strong> to <strong>GET </strong>and insert the base URL for retrieving multiple streams <a href="https://livepeer.com/api/stream?streamsonly=1"><strong>https://livepeer.com/api/stream?streamsonly=1</strong></a></li><li>Remember that the body should have the <strong>none radio button</strong> selected since we are not passing in any data</li><li>Click the blue send button and it should confirm with a response of status <strong>200</strong> meaning that the request went through and a response back with a list of your streams</li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*cG_rtNfbgmGTsgOYt8yzVA.png" /></figure><p><strong>Step 8: </strong>Toggling a stream</p><ul><li>Replace <strong>GET </strong>with <strong>Patch</strong> and insert the URL for for toggling recording <a href="https://livepeer.com/api/stream/%7Bid%7D/record"><strong>https://livepeer.com/api/stream/{id}/record</strong></a><strong> </strong>and replace <strong>{id}</strong> with the one you have at the end of <strong>Step 5</strong></li><li>Now we will toggle the recording on by putting the following in body, just as we did in <strong>Step 5</strong></li></ul><pre>{<br>“record”: true<br>}</pre><ul><li>Click the blue send button and it should confirm with a response of status <strong>204</strong> meaning that the request went through</li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*G-7OdKSnfivoG7o8c-xgEg.png" /></figure><p><strong>Step 9: </strong>Update a stream</p><ul><li>Select <strong>Patch</strong> and insert the URL for updating a stream <a href="https://livepeer.com/api/stream/%7Bid%7D"><strong>https://livepeer.com/api/stream/{id}</strong></a><strong> </strong>and replace <strong>{id}</strong> with the one you have at the end of <strong>Step 5</strong></li><li>Now we will not have the recording on and suspend the stream by putting the following in body, just as we did in <strong>Step 5</strong></li></ul><pre>{<br>“record”: false,<br>“suspend”: true<br>}</pre><ul><li>Click the blue send button and it should confirm with a response of status <strong>204</strong> meaning that the request went through</li></ul><figure><img alt="Postman dasboard" src="https://cdn-images-1.medium.com/max/1024/1*UVfHefbgQKL_W3p2uc1zVA.png" /></figure><p><strong>Step 10:</strong> Delete a stream</p><ul><li>We will delete <strong>Second Stream</strong> by replacing <strong>Patch </strong>with <strong>Delete </strong>and insert the URL for deleting a stream <a href="https://livepeer.com/api/stream/%7Bid%7D"><strong>https://livepeer.com/api/stream/{id}</strong></a><strong> </strong>and replace the {id} you have at the end of <strong>Step 5</strong></li><li>Click the blue send button and you should get a status <strong>204</strong> as a response to confirm the stream has been deleted</li></ul><figure><img alt="Postman dashboard" src="https://cdn-images-1.medium.com/max/1024/1*Kyu5u2YhUQvHPqq1gy64KQ.png" /></figure><ul><li>Go back to Livepeer Video Services’ dashboard to confirm that the stream has been deleted</li></ul><figure><img alt="Livepeer Video Services’ dashboard" src="https://cdn-images-1.medium.com/max/1024/1*DjHBpaU9gxF5fvjtk1SgMg.png" /></figure><p>Now that you are able to use Postman to interact with Livepeer Video Services’ API, take your skills to another level using cURL. To learn more, check out the tutorial How to Stream With Livepeer Video Service’s RTMP API.</p><p><a href="https://livepeer.com/blog/streaming-with-rtmp-api">How to Stream with RTMP API</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d402b52b3c7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What to know about RTMP]]></title>
            <link>https://medium.com/@shihyuhwang/what-to-know-about-rtmp-2a7ff3540f6d?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a7ff3540f6d</guid>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[livepeer]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 23:14:51 GMT</pubDate>
            <atom:updated>2022-02-25T23:32:06.203Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Train on a bridge" src="https://cdn-images-1.medium.com/max/1024/0*FpAK07knPbxrKe4l" /><figcaption>Photo by <a href="https://unsplash.com/@adryan_ra?utm_source=medium&amp;utm_medium=referral">Adryan RA</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>These four letters are used a lot in the video development world, but what does it mean and what is it for? In this article, we will go into the meaning of RTMP, its workflow and how it works in general.</p><p>RTMP or Real-Time Messaging Protocol is a type of transporting protocol also known as TCP or Transmission Control Protocol. Transporting protocols are responsible for delivering information from a media server to a user whether through the use of a CDN or directly to the video player. RTMP has been used more as a method of transporting data for a while due to being around for a long time. However, there is another transfer protocol called SRT that is gaining popularity. To learn more about SRT and Livepeer, read our article <a href="https://livepeer.com/blog/livepeer-now-supports-srt">Start Using SRT with Livepeer</a>.</p><p>Synonymous with Flash player, RTMP was developed by Macromedia and later acquired by Adobe, which they rebranded to Adobe Flash Player. Key features of RTMP include streaming at low-latency (~5 seconds) with minimal buffering and it being bi-directional, meaning that it can send and receive video data. There are other variations of RTMP such as RTMP, RTMPS, RTMPE, RTMPT, RTMPF.</p><p>Though the benefits are useful, it is no longer as supported or updated. Nor does it have much compatibility with most web browsers, iOS or Android devices. Another shortcoming of RTMP is that it can only deliver two channels for audio. This means RTMP can not deliver audio with more than one language.</p><h4>RTMP delivery workflow</h4><p>As a delivery protocol, RTMP takes the data and is able to break it down into smaller pieces of information known as chunks. It then determines the proper chunk size to send and does this in a continuous manner. This is how it is able to generate a constant connection for live streaming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YkVsD24EOaV7uHHq" /><figcaption>RTMP delivery workflow chart</figcaption></figure><h4>RTMP ingest workflow</h4><p>Nowadays, RTMP is often used more for transferring data from the encoder to the media server than for delivering from the media server to the CDN or video player. A main reason is because Adobe Flash Player is no longer supported and more adoption of HLS as the transfer protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y8Q9Mg0Z2dHre1nSztNadg.png" /><figcaption>RTMP Ingest workflow chart</figcaption></figure><p>Here is an outline of how the ingesting method works:</p><p><strong>Handshake </strong>— data being exchanged between client and server (3 chunks of data)</p><ul><li>Chunk 1 — Informs server which variation of RTMP being used</li><li>Chunk 2 — Contains the timestamp</li><li>Chunk 3 — Confirms first two data chunks and then starts connection</li></ul><p><strong>Connection</strong></p><ul><li>Send information that contains the type of application, audio codec and video codec being used</li></ul><p><strong>Stream</strong></p><ul><li>Send information on transaction ID, stream ID, and other parameters to create stream</li></ul><h4>RTMP ingest with Livepeer</h4><p>Livepeer offers a convenient way to get an ingest point and start streaming with ease. To learn more on how to do so, check out this article <a href="https://livepeer.com/blog/New-Dashboard">New Dashboard for Livepeer.com’s Streaming API</a>.</p><p>For those who want to build Livepeer into their own applications for a more customizable experience to give to their users, visit <a href="https://livepeer.com/blog/streaming-with-rtmp-api">Streaming with RTMP</a> for a more in-depth use of RTMP to stream with Livepeer with the API.</p><p><a href="https://livepeer.com/docs/api-reference">Learn more about the Livepeer API</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a7ff3540f6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Livepeer now supports SRT]]></title>
            <link>https://medium.com/@shihyuhwang/livepeer-now-supports-srt-325041495835?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/325041495835</guid>
            <category><![CDATA[videos]]></category>
            <category><![CDATA[content-cre]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Thu, 17 Feb 2022 15:19:07 GMT</pubDate>
            <atom:updated>2022-02-17T15:19:07.253Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Highway at night" src="https://cdn-images-1.medium.com/max/1024/0*zB4HRyMy0hXgftlB" /><figcaption>Photo by <a href="https://unsplash.com/@citytourvn?utm_source=medium&amp;utm_medium=referral">citytourvn</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What’s SRT?</h4><p>Secure Reliable Transport (SRT) is an open source video transport protocol developed by Haivision, that excels at providing stable streaming at relatively low latency. Although SRT is primarily used in broadcasting and corporate environments, SRT is increasingly becoming popular for all kinds of streaming over the internet.</p><p>Before going into more details on why the SRT protocol is gaining more adoption compared to the more traditional transport protocol such as RTMP and RTSP, let’s take a brief look at where it fits in the context of live video streaming.</p><h4>Live video streaming workflow</h4><p>Here is a simplified process of how live streaming works:</p><p><strong>Cameras and Microphones</strong></p><p>Source used for broadcasting video and/or audio</p><p><strong>Encoding</strong></p><p>Compresses the raw data from cameras and/or microphones for easier transporting across the internet</p><p><strong>Transcoding </strong><em>*SRT</em></p><p>Compresses the encoded data to smaller sizes and different formats to be more accessible across different types of devices</p><p><strong>Media servers</strong></p><p>Converts and repackages transcoded data as needed to be available for different types of formats chosen to view the video</p><p><strong>Content Delivery Network</strong></p><p>Quickly distributes the content provided by the media server from the nearest location requested by the viewer</p><p><strong>Video players and playback</strong></p><p>Decodes the data from the CDN and displays it for viewing</p><h4>In depth on SRT</h4><p>SRT is part of the transcoding process that delivers the data to the media server. Due to the nature of data getting transferred constantly in different variations, maintaining the optimum quality from the original source is very important.</p><p>There are features in SRT that assists in maintaining high quality data when transferring them.</p><p>Here are some unique features provided by SRT that help preserve the quality of data that is being transferred.</p><ul><li>The ability to configure the time to synchronize to multiple feeds</li><li>The ability to set and adjust the bandwidth</li><li>Reconstruct NAK(Negative Acknowledgement) packages to provide a smoother experience</li><li>More adaptability by being codec agnostic for audio and video</li></ul><p>We like SRT not only because it’s being actively maintained and is open-sourced, but also because SRT is designed to be highly stable and perform well in unpredictable network conditions by adapting to real-time network conditions. Another important aspect is that it also provides for security for the content distribution by using AES encryption.</p><p>Simply put: more reliable video means happier viewers.</p><p>SRT is still relatively new and not as widespread as RTMP, which means that you can’t stream SRT into popular live-streaming sites like Youtube, Twitch, and Facebook. Livepeer supporting SRT means that your streamers can stream SRT and get all the stability and security improvements that it was designed to deliver.</p><h4>Using SRT with Livepeer</h4><p>SRT streaming is simple to use. Currently, we provide a RTMP ingest URL like the following example:</p><figure><img alt="RTMP URL" src="https://cdn-images-1.medium.com/max/1024/1*Nia-WGf1Uhj0S2xbpyFiEg.png" /></figure><p>To use SRT transport method, simply replace the RTMP ingest URL with:</p><figure><img alt="SRT URL" src="https://cdn-images-1.medium.com/max/1024/1*XWuBqJwvWXYc-d3N3w11Xg.png" /></figure><p>Another easy option is that the SRT ingest URL is located right under the RTMP URL in the Livepeer dashboard. If you are using the SRT URL from the dashboard, there is no need to provide the stream key as it is already included.</p><figure><img alt="Livepeer Dashboard" src="https://cdn-images-1.medium.com/max/1000/1*zzV7v3eHtrw56EBsn1zhVQ.png" /></figure><p><strong>Below is an example of using SRT with OBS</strong></p><p>Go to settings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_d74iAorydNZMSy2z6tiNA.png" /></figure><p>Then select the <strong>Stream </strong>tab in the left menu</p><p>Select custom from the <strong>Service</strong> drop down menu</p><p>Paste in the SRT URL in the <strong>Server</strong> field</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvnAOMlcKZ3qIg74tu6m3Q.png" /></figure><p>Paste in the SRT ingest URL from Livepeer Video Services. Note that {stream_key} should be replaced with the given key, e.g. 56g6-xcd1-toox-w70z</p><p>And that’s it!</p><p>SRT is free to use for all accounts. For more information to get started using SRT, check out our documentation. Here is more information on getting started using SRT in <a href="https://livepeer.com/">Livepeer</a>, also check out our documentation. Happy streaming!</p><p><a href="https://livepeer.com/docs/guides/start-live-streaming/srt-support">Read SRT docs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=325041495835" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to stream live with Livepeer]]></title>
            <link>https://medium.com/@shihyuhwang/how-to-stream-live-with-livepeer-7c74fdfa7098?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c74fdfa7098</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[live-streaming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Tue, 18 Jan 2022 17:25:39 GMT</pubDate>
            <atom:updated>2022-01-18T17:29:36.783Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will go through all the steps to build a simple website using html that will playback our live stream using Livepeer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iEr4Gx0kGgMirBoB" /><figcaption>Photo by <a href="https://unsplash.com/@shnipelson?utm_source=medium&amp;utm_medium=referral">Jana Shnipelson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Workflow for live streaming</h3><p>When creating a live stream there are some equipments involved for the streamer. A live stream needs to have a video source for capturing the visuals, an audio source to capture the sounds, if any that goes with the video. After that is established, the raw data from both sources needs to be encoded so that it can be transmitted over the internet. Afterwards, this data then needs to be converted to the ideal formats regardless of what the device is for viewing. This is what the transcode does. Finally, a player of some sort is used to play back the final version of the data and is what the viewer will see.</p><p>Below are simplified steps to create a simple live stream:</p><p>When creating a live stream there are some equipments involved for the streamer. A live stream needs to have a video source for capturing the visuals, an audio source to capture the sounds, if any that goes with the video. After that is established, the raw data from both sources needs to be encoded so that it can be transmitted over the internet. Afterwards, this data then needs to be converted to the ideal formats regardless of what the device is for viewing. This is what the transcode does. Finally, a player of some sort is used to play back the final version of the data and is what the viewer will see.</p><p>Below are simplified steps to create a simple live stream:</p><pre>+---------------+-------------------------------------+<br>| Equipment     | Description                         |      <br>+ ------------- +-------------------------------------+<br>| DJI OSMO+     | built-in camera from DJI OSMO+      |<br>| DJI OSMO+     | built-in microphone from DJI OSMO+  |<br>| Encoder       | DJI App                             |<br>| Transcoder    | Livepeer                            |<br>| Video player  | JWPlayer                            |<br>+---------------+-------------------------------------+</pre><p>We will do the following steps:</p><p>✔️ Create <a href="https://livepeer.com/">Livepeer</a> account</p><p>✔️ Create a <a href="https://www.jwplayer.com/">JWPlayer</a> account</p><p>✔️ Download <a href="https://www.dji.com/downloads/djiapp/dji-go-3">DJI Go</a> broadcaster</p><p>✔️ Create our project</p><h3>Using Livepeer</h3><ul><li>Open a browser and go to <a href="https://livepeer.com/register">Livepeer</a> site and sign up for a free account.</li></ul><figure><img alt="Liveppeer homepage" src="https://cdn-images-1.medium.com/max/1024/1*812ddV4lGk1RbjlWQ7P3SQ.png" /></figure><figure><img alt="Livepeer new account page" src="https://cdn-images-1.medium.com/max/1024/1*iVSQqY0GHi-Ewt2SNFC6rA.png" /></figure><ul><li>Click on the Upload from URL button and paste in the Playback URL from Livepeer.</li></ul><figure><img alt="Livepeer dashboard page" src="https://cdn-images-1.medium.com/max/1024/1*xJOzI507pqWHBsJ8hhcMAg.png" /></figure><figure><img alt="Livepeer streams page" src="https://cdn-images-1.medium.com/max/1024/1*eQD2yMPybOVIiEOHv5Ew2Q.png" /></figure><figure><img alt="Livepeer create new stream page" src="https://cdn-images-1.medium.com/max/1024/1*smOst5NRJzsOannFgeDjFQ.png" /></figure><blockquote><em>This should create a dashboard for this stream and provide information that we will need for other set up processes. For now, we will only need the </em><em>Stream Key, </em><em>RTMP ingest URL, and the </em><em>Playback URL.</em></blockquote><figure><img alt="Livepeer stream dashboard page" src="https://cdn-images-1.medium.com/max/1024/1*qvHe8mQWYSeR3K9RwslOhw.png" /></figure><h3>Using JWPlayer</h3><ul><li>In a separate browser tab, go to <a href="https://info.jwplayer.com/sign-up/">JWPlayer</a> and sign up for a free account.</li></ul><figure><img alt="JWPlayer homepage" src="https://cdn-images-1.medium.com/max/1024/1*Trdsqbf82bFyFRd_EGHxDQ.png" /></figure><figure><img alt="JWPlayer create new account page" src="https://cdn-images-1.medium.com/max/1024/1*Pvn4t2GT6ha1wbKSzpOmgQ.png" /></figure><ul><li>Click on the Upload from URL button and paste in the Playback URL from Livepeer.</li></ul><figure><img alt="JWPlayer media page" src="https://cdn-images-1.medium.com/max/1024/1*GbvI4s16jsXFyWZ87t7Vxw.png" /></figure><figure><img alt="JWPlayer create URL page" src="https://cdn-images-1.medium.com/max/621/1*1kW1RzkZowqJ7zxAdDvlQQ.png" /></figure><blockquote>For this tutorial, we can just select the No, don&#39;t host media on import option.</blockquote><ul><li>Then click on Add URLs button and player is created for our live streaming.</li></ul><figure><img alt="JWPlayer new player dashboard" src="https://cdn-images-1.medium.com/max/1024/1*rvVMHrqg1BuxVgf6C9VIFA.png" /></figure><h3>Installing DJI Go</h3><ul><li>Go to <a href="https://www.dji.com/downloads/djiapp/dji-go-3">DJI Go</a> website and download to your mobile device.</li><li>Open the app and select your device.</li></ul><blockquote>In this example, DJI OSMO+ will be used</blockquote><figure><img alt="DJI Go app home screen" src="https://cdn-images-1.medium.com/max/296/1*6Gf81XOn_brzLZkPGUhEkw.png" /></figure><blockquote>After the app is installed, the app needs to connect to the DJI network. Here is the instructions on how:</blockquote><pre>On your mobile device, connect to the ‘OSMO_XXXXXX’ Wi-Fi network.<br>Enter the password: 12341234, then launch the DJI GO App on your mobile device.<br>Find OSMO in the App and enter Camera View.</pre><ul><li>Once the app is connected to the network, click on the gear icon in the top right corner and choose Select Live Broadcast Platform at the bottom</li></ul><figure><img alt="Camera screen for DJI app" src="https://cdn-images-1.medium.com/max/296/1*pE24rbz44u6-Wc9BfTPc3w.png" /></figure><figure><img alt="Settings screen for DJI app" src="https://cdn-images-1.medium.com/max/296/1*lK9-C2arB1NHaTqFg7XPjQ.png" /></figure><p>Now select the RTMP Custom option and add information for Livepeer streaming, enter the following information:</p><ul><li>Add the RTMP ingest URL: rtmp://rtmp.livepeer.com/live/</li><li>Then add your stream key right after it.</li></ul><figure><img alt="Broadcast selection screen in DJI app" src="https://cdn-images-1.medium.com/max/296/1*ftDDkBDkLro6iQgD0-tsfg.png" /></figure><figure><img alt="Custom broadcast screen for DJI app" src="https://cdn-images-1.medium.com/max/295/1*HXjhd_oRHlfophGISW9k5g.png" /></figure><p>Tap Next button and a confirmation page should show</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*l06ZDxKVWQo3VqWEaLGVbg.png" /></figure><p>We are now up and running for live streaming, but let’s make this viewable on a simple website so others can see.</p><blockquote><em>Before we start the website, first get the embed code from JWPlayer by clicking the </em><em>Embed button on the top of the page next to the red </em><em>Save button. A window should pop up and give you option to select the type of embed code. For this example, we will choose the IFrame format and give it a little more style.</em></blockquote><h3>Directory and file setup</h3><p>Find a location on your computer for where you want this file to be stored. Create a directory for it and a html file.</p><pre>mkdir streamDemo &amp;&amp; touch index.html</pre><p>Now change into the directory that we just created and open it with the code editor of your choice.</p><pre>cd streamDemo</pre><p>In the index.html file, we will create a simple web page, enter the code below into the file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d7bb51714169670ba65d8d2369f410f/href">https://medium.com/media/6d7bb51714169670ba65d8d2369f410f/href</a></iframe><p>Now we have completed a very simple website that we can do some live streaming on!</p><p>Thanks for taking the time to read this article and I hope you find it useful.</p><p>Stay tuned for more articles on live streaming, video technology and much more!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c74fdfa7098" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cronos Testnet Deployment]]></title>
            <link>https://medium.com/coinmonks/cronos-testnet-deployment-57f390fc8ab5?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/57f390fc8ab5</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Mon, 10 Jan 2022 22:59:53 GMT</pubDate>
            <atom:updated>2022-01-16T03:26:25.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AZrSSOr6zwvo0Yic" /><figcaption>Photo by <a href="https://unsplash.com/@billy_huy?utm_source=medium&amp;utm_medium=referral">Billy Huynh</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this article, we will explore how to deploy a Simple storgage contract from Truffle to the Cronos testnet.</p><h3>About</h3><p>Truffle is a development environment for writing smart contracts on the Ethereum blockchain. It allows developers to:</p><ul><li>Compile contracts</li><li>Test contracts</li><li>Deploy contracts</li><li>Debug contracts</li></ul><p>Cronos Chain is a EVM that runs parallel on to Crypto.org’s blockchain</p><p>It provides many usability including:</p><ul><li>EVM Compatibility</li><li>Fast and efficient scalability</li><li>Easy to port Dapps from Etheruem and other EVM compatible chains</li></ul><p>You can learn more about each here:</p><p><a href="https://www.trufflesuite.com/docs/truffle/overview">TruffleSuite</a></p><p><a href="https://cronos.crypto.org/">Cronos Chain</a></p><h3>Project Setup</h3><p>The first step we need to do is set up a project with Truffle before we start writing our smart contract.</p><ul><li>Go to the folder where you want the project to live</li></ul><pre>mkdir &lt;project name&gt;</pre><ul><li>Then move into that folder you just created</li></ul><pre>cd &lt;project name&gt;</pre><p>Now we will install Truffle into out project with the following command:</p><pre>truffle init</pre><p>You should get a similar output</p><pre>Starting init...</pre><pre>================</pre><pre>&gt; Copying project files to /Users/Desktop/cronos-truffle-example</pre><pre>Init successful, sweet!</pre><pre>Try our scaffold commands to get started:</pre><pre>$ truffle create contract YourContractName # scaffold a contract</pre><pre>$ truffle create test YourTestName         # scaffold a test</pre><pre>http://trufflesuite.com/docs</pre><p>Next install npm so that we can add a couple of dependencies.</p><p>Use the following command to install npm.</p><pre>npm i -y</pre><blockquote>You can use <strong><em>npm i</em></strong>, I chose to use <strong><em>-y </em></strong>to bypass each setup step questions during the install</blockquote><p>Once we installed npm, we will import two dependencies we will use for our project.</p><ul><li><a href="https://www.npmjs.com/package/dotenv">dotenv</a>( to hide our private keys)</li><li><a href="https://trufflesuite.com/docs/truffle/reference/configuration.html">Truffle’s HDWalletProvider</a>(as a Web3 provider)</li></ul><p>Run the following command to install them both</p><pre>npm i dotenv @truffle/hdwallet-provider</pre><h3>Writing the smart contract</h3><p>Inside the contracts directory, create a new file and name it <strong><em>SimpleStorage.sol</em></strong></p><p>Then put the following code into the file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bb5225d640ced0232dd0f97c35de85ea/href">https://medium.com/media/bb5225d640ced0232dd0f97c35de85ea/href</a></iframe><blockquote>We won’t get into too much of the code since this tutorial is more about deploying a contract using Truffle to the Cronos Testnet. Here is information on writing smart contracts using <a href="https://docs.soliditylang.org/en/latest/"><strong><em>Solidity</em></strong></a></blockquote><p>Next, we will have to write a migration script.</p><p>Inside the <strong><em>migrations</em></strong> directory, add another file and name it <strong><em>2_deploy_SimpleStorage.js</em></strong></p><p>Now inside the file, write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cb21a3ab246dfd736c674ed16603058/href">https://medium.com/media/0cb21a3ab246dfd736c674ed16603058/href</a></iframe><blockquote>To learn more on how migrations in Truffle works <a href="https://trufflesuite.com/docs/truffle/getting-started/running-migrations.html">here</a></blockquote><h3>Cronos Testnet Configuration</h3><p>Now that we have a smart contract, we first have to configure the network before we are able to deploy it to the testnet.</p><p>Let’s set up the Cronos testnet configuration by going into the <strong><em>truffle-config.js</em></strong> file</p><p>There are a lot of information about how to use this file, but we will simplify it.</p><p>Right above the <strong><em>module.exports = {</em></strong> , we will add the following:</p><pre>require(&quot;dotenv&quot;).config();</pre><pre>const HDWalletProvider = require(&#39;@truffle/hdwallet-provider&#39;);</pre><p>Here we are getting the <strong><em>dotenv</em></strong> package to hide our private key later on and also getting the <strong><em>HDWalletProvider</em></strong> as a Web3 provider</p><p>Next, we will setup the Cronos testnet configuration.</p><p>Inside the <strong><em>networks: {</em></strong> find the rospten network and replace it with the following code:</p><pre>cronosTestnet: {</pre><pre>provider: () =&gt; new HDWalletProvider(process.env.PRIVATE_KEY, &quot;https://cronos-testnet-3.crypto.org:8545&quot;),</pre><pre>network_id: &quot;*&quot;,       // Cronos&#39;s testnet id</pre><pre>skipDryRun: true</pre><pre>},</pre><p>This code added the Cronos testnet address <strong><em>https://cronos-testnet-3.crypto.org:8545</em></strong> to the config file and uses the <strong><em>HDWalletProvider</em></strong> to connect to with by using a given private key from an account.</p><p>Let’s simply the whole file and the code should look like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/578e3fa7b8d59332be14561bae51adb6/href">https://medium.com/media/578e3fa7b8d59332be14561bae51adb6/href</a></iframe><h3>Setting Up Test Account</h3><p>Before we can deploy our contract, we first have to connect our wallet to the testnet. In order to do so, we will configure it using Metamask.</p><p>You can find out more about <a href="https://metamask.io/">Metamask</a></p><ul><li>Log into Metamask</li><li>Under the network menu at the top, click on the button to <strong><em>Add Network</em></strong></li><li>Input the following information to add a new network:</li></ul><pre>Network Name: &lt;Name to call Cronos Testnet&gt;</pre><pre>- RPC Url : https://cronos-testnet-3.crypto.org:8545/</pre><pre>- ChainId: 338</pre><pre>- Symbol: tCro</pre><pre>- Block Explorer URL: https://cronos.crypto.org/explorer/testnet3/</pre><p>Once the testnet is added to Metamask, we fill fund it with some test Cronos.</p><p>Go to the <a href="https://cronos.crypto.org/faucet">faucet</a> and fund the account you will be testing with.</p><p>Now that we have setup our test network and have <strong><em>tCro</em></strong>, the last thing we need to do before deploying our contract is to pass in our account’s private key in our <strong><em>truffle-confi</em></strong>g file.</p><p>In order to do this more securely, we will store the private key in a <strong><em>.env</em></strong> file.</p><p>In the root directory of the project, type in the following command:</p><pre>touch .env</pre><p>This will create a file called <strong><em>.env</em></strong> in the root directory.</p><p>Inside this directory, we will assign a the variable <strong><em>PRIVATE_KEY=</em></strong> our private key</p><p>To get the private key, go to the Metamask account you are using for the test and when you click the 3 dots next to it, select the <strong><em>Account details</em></strong></p><p>Select the <strong><em>Export Private Key</em></strong> button. Metamask will ask for your account password and once you type that in, you should be given the private key. Now copy this key into the<strong><em> .env</em></strong> file.</p><p>It should look similar to the following.</p><pre>PRIVATE_KEY=e902eef0dd0a0c03845b9b743c7834839</pre><blockquote>Note that this is not a real private and is used for demonstration purpose</blockquote><p>Since we already declared this variable in our <strong><em>truffle-config</em></strong> file in the <strong><em>HDWallet-Provder</em></strong> method, we do not have to do anything else.</p><pre>provider: () =&gt; new HDWalletProvider(process.env.PRIVATE_KEY, `https://cronos-testnet-3.crypto.org:8545`),</pre><h3>Deploy smart contract</h3><p>Now that we have:</p><p>✔️ A smart contract</p><p>✔️ Network configuration setup</p><p>✔️ Connected Metamask account to the testnet</p><p>✔️ Fund the account with test tokens</p><p>We are able to deploy our contract to the testnet:</p><p>In the root directory of the project, we can run the following truffle command to deploy our contract:</p><pre>truffle deploy --network cronosTestnet</pre><p>You should get similar output in the terminal</p><pre>Compiling your contracts...</pre><pre>===========================</pre><pre>&gt; Everything is up to date, there is nothing to compile.</pre><pre>Starting migrations...</pre><pre>======================</pre><pre>&gt; Network name:    &#39;cronosTestnet&#39;</pre><pre>&gt; Network id:      338</pre><pre>&gt; Block gas limit: 81500000 (0x4db9760)</pre><pre>1_initial_migration.js</pre><pre>======================</pre><pre>Deploying &#39;Migrations&#39;</pre><pre>----------------------</pre><pre>&gt; transaction hash:    0x5be6f16117df6f65b170af759df881be8afc8f6b144790cec2fe26dc2ee8eeb7</pre><pre>&gt; Blocks: 0            Seconds: 4</pre><pre>&gt; contract address:    0xAAEc9B476c0897d7A4b80Cdd61314446A402237e</pre><pre>&gt; block number:        1301726</pre><pre>&gt; block timestamp:     1641843771</pre><pre>&gt; account:             0x2880627569ffA41965536CE20B0596009eDfA744</pre><pre>&gt; balance:             98.74523</pre><pre>&gt; gas used:            250954 (0x3d44a)</pre><pre>&gt; gas price:           5000 gwei</pre><pre>&gt; value sent:          0 ETH</pre><pre>&gt; total cost:          1.25477 ETH</pre><pre>&gt; Saving migration to chain.</pre><pre>&gt; Saving artifacts</pre><pre>-------------------------------------</pre><pre>&gt; Total cost:             1.25477 ETH</pre><pre>2_deploy_SimpleStorage.js</pre><pre>=========================</pre><pre>Deploying &#39;SimpleStorage&#39;</pre><pre>-------------------------</pre><pre>&gt; transaction hash:    0x4feb1d3bd554d44a12e115646448224d36be69d8d9626f4d83e181c6bd97b50a</pre><pre>&gt; Blocks: 1            Seconds: 5</pre><pre>&gt; contract address:    0x68118E9543a5CBded1d7255844b0FA40177C9641</pre><pre>&gt; block number:        1301730</pre><pre>&gt; block timestamp:     1641843795</pre><pre>&gt; account:             0x2880627569ffA41965536CE20B0596009eDfA744</pre><pre>&gt; balance:             96.97724</pre><pre>&gt; gas used:            308985 (0x4b6f9)</pre><pre>&gt; gas price:           5000 gwei</pre><pre>&gt; value sent:          0 ETH</pre><pre>&gt; total cost:          1.544925 ETH</pre><pre>⠋ Saving migration to chain.</pre><p>You should also notice that the amount of your test tokens has reduced.</p><p>Finally, you can check that the contract has been deployed to Cronos’ testnet by getting the contracts address that was created in the output of the terminal when it was deployed and paste it into Cronos’ testnet block explorer <a href="https://cronos.crypto.org/explorer/testnet3/"><strong><em>Here</em></strong></a></p><p>The result should look something similar to this:</p><figure><img alt="Screen shot of Cronos testnet transaction" src="https://cdn-images-1.medium.com/max/1024/1*YTM7iAeDhQKImL9mmZjzBg.png" /></figure><p>You can see that the contract was created and a transaction has been made to the contract on the Cronos testnet.</p><p>Thanks for reading this article and I hope you find it useful.</p><p>Stay tuned for more articles on blockchain, smart contracts and much more!</p><blockquote>Join Coinmonks <a href="https://t.me/coincodecap">Telegram Channel</a> and <a href="https://www.youtube.com/c/coinmonks/videos">Youtube Channel</a> learn about crypto trading and investing</blockquote><h4>Also Read</h4><ul><li><a href="https://blog.coincodecap.com/blockfi-review">BlockFi Review 2021: Pros, Cons and Interest Rates | CoinCodeCap</a></li><li><a href="https://medium.com/coinmonks/buy-bitcoin-in-india-feb50ddfef94">Top 6 Crypto Trading Apps in India — Best Exchanges</a></li><li><a href="https://medium.com/coinmonks/best-crypto-tax-tool-for-my-money-72d4b430816b">10 Best FREE Crypto Tax Software in 2024</a></li><li><a href="https://blog.coincodecap.com/crypto-to-buy-in-2022">9 Best Crypto to Buy in 2022 | CoinCodeCap</a></li><li><a href="https://blog.coincodecap.com/best-hardware-wallet-bitcoin">Best Crypto Hardware Wallets to Store Bitcoin [2021] | CoinCodeCap</a></li><li><a href="https://medium.com/coinmonks/pionex-review-exchange-with-crypto-trading-bot-1e459d0191ea">Pionex Review 2022 — Free Crypto Trading Bots</a></li><li><a href="https://medium.com/coinmonks/top-3-telegram-channels-for-crypto-traders-in-2021-8385f4411ff4">12 Best FREE Crypto Telegram Channels 2023 (Trading Signals)</a></li><li><a href="https://blog.coincodecap.com/free-crypto-portfolio-trackers">5 Best Free Crypto Portfolio Trackers 2022 | CoinCodeCap</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57f390fc8ab5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/cronos-testnet-deployment-57f390fc8ab5">Cronos Testnet Deployment</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Setup Using Hardhat & Truffle — part 5]]></title>
            <link>https://medium.com/coinmonks/project-setup-using-hardhat-truffle-part-5-2d66dbc2c3c3?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d66dbc2c3c3</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Fri, 07 Jan 2022 18:18:11 GMT</pubDate>
            <atom:updated>2022-01-08T06:05:55.580Z</atom:updated>
            <content:encoded><![CDATA[<h3>Project Setup Using Hardhat &amp; Truffle — part 5</h3><figure><img alt="Computer screen with code" src="https://cdn-images-1.medium.com/max/1024/0*_BW_GZqp-EB1fia6" /><figcaption>Photo by <a href="https://unsplash.com/@mahesh_ranaweera?utm_source=medium&amp;utm_medium=referral">Mahesh Ranaweera</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For the final part of this project, we are going to connect our contract to the front end with React. Since this is about writing smart contracts, we won’t go too much in to styling the page.</p><h3>Frontend setup with Truffle</h3><h4>Checklist</h4><p>Here is a quick check list before connect to the frontend</p><ul><li>Ganache is still running</li><li>Our contract is compiled and the <strong><em>build</em></strong> directory is under our <strong><em>src</em></strong> directory</li><li>In another terminal, change into <strong><em>src</em></strong> directory of this project</li></ul><pre>cd truffle-example/src</pre><ul><li>Run <strong><em>npm start </em></strong>to make sure React is working and you should get something similar to the following:</li></ul><pre>Compiled successfully!</pre><pre>You can now view truffle-example in the browser.</pre><pre>Local:            http://localhost:3000</pre><pre>On Your Network:  http://192.168.5.107:3000</pre><pre>Note that the development build is not optimized.</pre><pre>To create a production build, use yarn build.</pre><p>Now that everything is set up, lets connect the frontend to our contract</p><p>Under the <strong><em>src</em></strong>, find the file<strong><em> App.js</em></strong>, the default code should look like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5763cc393b7f1a6456051924edaf5848/href">https://medium.com/media/5763cc393b7f1a6456051924edaf5848/href</a></iframe><p>Now remove the following code and we will write our own script, the result should be a blank page</p><pre>import &#39;./App.css&#39;;<br></pre><pre>function App() {</pre><pre>return (</pre><pre>&lt;div className=&quot;App&quot;&gt;</pre><pre>&lt;header className=&quot;App-header&quot;&gt;</pre><pre>&lt;h1&gt;Welcome to Number Changer&lt;/h1&gt;</pre><pre>&lt;h3&gt;Your new number:&lt;/h3&gt;</pre><pre>&lt;input /&gt;</pre><pre>&lt;button&gt;Get Number&lt;/button&gt;</pre><pre>&lt;button&gt;Set Number&lt;/button&gt;</pre><pre>&lt;/header&gt;</pre><pre>&lt;/div&gt;</pre><pre>);</pre><pre>}</pre><pre>export default App;</pre><p>Your page should now look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*Lqz79fvHIxtl8d7DZcrxOw.png" /></figure><h4>Interacting with the blockchain</h4><p>First we need to install and import Web3.js library into our file, which allows us to interact with the blockchain</p><blockquote>Learn more about Web3.js library <a href="https://web3js.readthedocs.io/en/v3.0.0-rc.5/">here</a></blockquote><p>In the terminal, type:</p><pre>npm i web3</pre><p>and in App.js, add</p><pre>import Web3 from “web3”;</pre><p>Now we will need to import our contract ABI so that we can have access to our smart contract’s functions from the blockchain</p><pre>import NumberChanger from &quot;./build.NumberChanger.json&quot;;</pre><p>The first 3 lines of <strong><em>App.js</em></strong> should look like this</p><pre>import &#39;./App.css&#39;;</pre><pre>import Web3 from &quot;web3&quot;;</pre><pre>import NumberChanger from &quot;./build/NumberChanger.json&quot;;</pre><p>Now we need connect to the blockchain with <strong><em>Web3.js </em></strong>by creating an instance of it. Since we created a local blockchain with <strong><em>ganache-cli</em></strong>, the address will be on localhost:8545</p><pre>const web3 = new Web3(&quot;http://localhost:8545&quot;)</pre><blockquote>This is hard coded and will be different when you are connecting to the testnet or mainnet</blockquote><p>Next, we need to get our contracts address so Web3.js can connect to it. When Truffle migrated the smart contract, it gave information about the transaction and the contract’s address is one of them.</p><pre>2_NumberChanger.js</pre><pre>==================</pre><pre>Deploying &#39;NumberChanger&#39;</pre><pre>-------------------------</pre><pre>&gt; transaction hash:    0xc879826ffe4bb0d246edd988a414ad2b6544c85a8bde98cabd0e140c91ebd02f</pre><pre>&gt; Blocks: 0            Seconds: 0</pre><pre>&gt; contract address:    0x7c2481b87100844E11df966BcCD55E82A138Fe84</pre><pre>&gt; block number:        3</pre><pre>&gt; block timestamp:     1639941021</pre><pre>&gt; account:             0x8f506C687ec10f6c91B7E3A368aF150D970Ccbec</pre><pre>&gt; balance:             99.9916596</pre><pre>&gt; gas used:            125653 (0x1ead5)</pre><pre>&gt; gas price:           20 gwei</pre><pre>&gt; value sent:          0 ETH</pre><pre>&gt; total cost:          0.00251306 ETH</pre><pre>&gt; Saving migration to chain.</pre><pre>&gt; Saving artifacts</pre><pre>-------------------------------------</pre><pre>&gt; Total cost:          0.00251306 ETH</pre><p>We will now get the contract address and store it in a variable.</p><pre>const contractAddress = &quot;0x7c2481b87100844E11df966BcCD55E82A138Fe84&quot;;</pre><blockquote>Your contract address will be different from mine when it is deployed</blockquote><p>After we have our contract address and our contract’s ABI, we can now get our contract’s functions and call them. Let’s pass them through the Web3.js method <strong><em>Contract(contract ABI, contract’s address)</em></strong> store them in a variable called contract</p><pre>const contract = new web3.eth.Contract(NumberChanger.abi, contractAddress);</pre><blockquote>The contract’s abi must be appended with <strong><em>.abi</em></strong></blockquote><p>Your code should now look like the following:</p><pre>import &#39;./App.css&#39;;</pre><pre>import Web3 from &quot;web3&quot;;</pre><pre>import NumberChanger from &quot;./build/NumberChanger.json&quot;;</pre><pre>const contractAddress = &quot;0x7c2481b87100844E11df966BcCD55E82A138Fe84&quot;;</pre><pre>function App() {</pre><pre>const web3 = new Web3(&quot;http://localhost:8545&quot;);</pre><pre>let contract = new web3.eth.Contract(NumberChanger.abi, contractAddress);</pre><pre>return (</pre><pre>&lt;div className=&quot;App&quot;&gt;</pre><pre>&lt;header className=&quot;App-header&quot;&gt;</pre><pre>&lt;h1&gt;Welcome to Number Changer&lt;/h1&gt;</pre><pre>&lt;h3&gt;Your new number:&lt;/h3&gt;</pre><pre>&lt;input /&gt;</pre><pre>&lt;button&gt;Get Number&lt;/button&gt;</pre><pre>&lt;button&gt;Set Number&lt;/button&gt;</pre><pre>&lt;/header&gt;</pre><pre>&lt;/div&gt;</pre><pre>);</pre><pre>}</pre><pre>export default App;</pre><p>Now that we are able to interact with our contract on the blockchain, we will now write a function to get the current number from the state and set a new number by changing the state</p><p>Since we have to change state in React, import <strong><em>useState</em></strong> from <strong><em>react</em></strong></p><pre>import {useState} from &quot;react&quot;;</pre><p>Then we will declare in inside the function</p><pre>const [number, setNewNumber] = useState();</pre><p>Now we will create a function of getting the number from the contract</p><pre>async function getNumber() {</pre><pre>try {</pre><pre>const getStateNumber = await contract.methods.getNumber().call();</pre><pre>setNewNumber(getStateNumber);</pre><pre>} catch (error) {</pre><pre>console.log(&quot;Error:&quot;, error);</pre><pre>}</pre><pre>}</pre><p>We can get the value of the number stored in state from our contract by using the <strong><em>methods</em></strong> property of <strong><em>Contract </em></strong>, then the <strong><em>getNumber()</em></strong> function in our smart contract and finally using .<strong><em>call()</em></strong>to retrieve the number stored in the state variable</p><p>Now that we are able to retrieve the number set in state from the blockchain, let’s now write a function to change the state of number variable with a setter function</p><pre>async function changeNumber() {</pre><pre>// Assign array of accounts into getAccount variable</pre><pre>let getAccount = await web3.eth.getAccounts();</pre><pre>// Calling setNumber function and using first account to send transaction</pre><pre>await contract.methods.setNumber(number).send({ from: getAccount[0] });</pre><pre>// Resets input and h3 to blank</pre><pre>setNewNumber(&quot;&quot;);</pre><pre>}</pre><p>We get the accounts from Ganache using the <strong><em>getAccounts()</em></strong> method from Web3.js and then assign it a variable. Then using <strong><em>contract.methods</em></strong> similar to our <strong><em>getNumber()</em></strong> function, we will use it to call our <strong><em>setNumber()</em></strong> function from our smart contract from the blockchain and pass in the new number that the user will input. Then we will use the <strong><em>send()</em></strong> method and pass in the account we want to transact from.</p><p>The code should look like this…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ecf5cf34254f58f8c7c8052bd8cbb33/href">https://medium.com/media/5ecf5cf34254f58f8c7c8052bd8cbb33/href</a></iframe><p>Finally we will implement the functions and update the state on our page with the following in the <strong><em>return</em></strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0daa0c55c25bae2ce0f6a7df97a44245/href">https://medium.com/media/0daa0c55c25bae2ce0f6a7df97a44245/href</a></iframe><p>And the final code should look like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/274befcba3ee570fb98fc84f32bcb800/href">https://medium.com/media/274befcba3ee570fb98fc84f32bcb800/href</a></iframe><p>Now experiment by setting the number and then getting them. You should also notice the funds in the first account balance lower each time the number is set to pay for the transaction fee.</p><h3>Frontend setup with Hardhat</h3><h4>Checklist</h4><ul><li>Make sure HardHat node is running in the background</li><li>Our contract is compiled and the <strong><em>artifacts</em></strong> directory is under our <strong><em>src</em></strong> directory</li><li>In another terminal, change into <strong><em>src</em></strong> directory of this project</li></ul><pre>cd hardhat-example/src</pre><ul><li>Run <strong><em>npm start</em></strong> to make sure React is working and you should get something similar to the following:</li></ul><pre>Compiled successfully!</pre><pre>You can now view truffle-example in the browser.</pre><pre>Local:            http://localhost:3000</pre><pre>On Your Network:  http://192.168.5.107:3000</pre><pre>Note that the development build is not optimized.</pre><pre>To create a production build, use yarn build.</pre><p>Now that everything is set up, lets connect the frontend to our contract</p><p>Under the <strong><em>scr</em></strong>, find the file <strong><em>App.js</em></strong>, the default code should look like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5763cc393b7f1a6456051924edaf5848/href">https://medium.com/media/5763cc393b7f1a6456051924edaf5848/href</a></iframe><p>Now remove the following code and we will write our own script, the result should be a blank page</p><pre>import &#39;./App.css&#39;;</pre><pre>function App() {</pre><pre>return (</pre><pre>&lt;div className=&quot;App&quot;&gt;</pre><pre>&lt;header className=&quot;App-header&quot;&gt;</pre><pre>&lt;h1&gt;Welcome to Number Changer&lt;/h1&gt;</pre><pre>&lt;h3&gt;Your new number:&lt;/h3&gt;</pre><pre>&lt;input /&gt;</pre><pre>&lt;button&gt;Get Number&lt;/button&gt;</pre><pre>&lt;button&gt;Set Number&lt;/button&gt;</pre><pre>&lt;/header&gt;</pre><pre>&lt;/div&gt;</pre><pre>);</pre><pre>}</pre><pre>export default App;</pre><p>Your page should now look like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*Lqz79fvHIxtl8d7DZcrxOw.png" /></figure><h4>Interacting with the blockchain</h4><p>First we need to install and import Web3.js library into our file, which allows us to interact with the blockchain</p><blockquote>Learn more about Web3.js library <a href="https://web3js.readthedocs.io/en/v3.0.0-rc.5/">here</a></blockquote><p>In the terminal, type:</p><pre>npm i web3</pre><p>and in App.js, add</p><pre>import Web3 from “web3”;</pre><p>Now we will need to import our contract ABI so that we can have access to our smart contract’s functions from the blockchain</p><pre>import NumberChanger from &quot;../src/artifacts/contracts/NumberChanger.sol/NumberChanger.json&quot;;</pre><p>The first 3 lines of <strong><em>App.js</em></strong> should look like this</p><pre>import &#39;./App.css&#39;;</pre><pre>import Web3 from &quot;web3&quot;;</pre><pre>import NumberChanger from &quot;../src/artifacts/contracts/NumberChanger.sol/NumberChanger.json&quot;;</pre><p>Now we need connect to the blockchain with <strong><em>Web3.js</em></strong> by creating an instance of it. Since we created a local blockchain with <strong><em>npx hardhat node</em></strong>, the address will be on localhost:8545</p><pre>const web3 = new Web3(&quot;http://localhost:8545&quot;);</pre><blockquote>This is hard coded and will be different when you are connecting to the testnet or mainnet</blockquote><p>Next, we need to get our contracts address so Web3.js can connect to it. When Hardhat ran the deploy script <strong><em>npx hadhat run scripts/deploy.js</em></strong> it gave information about the contract’s address.</p><pre>Number deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512</pre><p>We will now get the contract address and store it in a variable.</p><pre>const contractAddress = &quot;0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512&quot;;</pre><blockquote>Your contract address will be different from mine when it is deployed</blockquote><p>After we have our contract address and our contract’s ABI, we can now get our contract’s functions and call them. Let’s pass them through the Web3.js method <strong><em>Contract(contract ABI, contract’s address) </em></strong>store them in a variable called contract</p><pre>const contract = new web3.eth.Contract(NumberChanger.abi, contractAddress);</pre><blockquote>The contract’s abi must be appended with <strong><em>.abi</em></strong></blockquote><p>Your code should now look like the following:</p><pre>import &#39;./App.css&#39;;</pre><pre>import Web3 from &quot;web3&quot;;</pre><pre>import NumberChanger from &quot;../src/artifacts/contracts/NumberChanger.sol/NumberChanger.json&quot;;</pre><pre>const contractAddress = &quot; 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512&quot;;</pre><pre>function App() {</pre><pre>const web3 = new Web3(&quot;http://localhost:8545&quot;);</pre><pre>let contract = new web3.eth.Contract(NumberChanger.abi, contractAddress);</pre><pre>return (</pre><pre>&lt;div className=&quot;App&quot;&gt;</pre><pre>&lt;header className=&quot;App-header&quot;&gt;</pre><pre>&lt;h1&gt;Welcome to Number Changer&lt;/h1&gt;</pre><pre>&lt;h3&gt;Your new number:&lt;/h3&gt;</pre><pre>&lt;input /&gt;</pre><pre>&lt;button&gt;Get Number&lt;/button&gt;</pre><pre>&lt;button&gt;Set Number&lt;/button&gt;</pre><pre>&lt;/header&gt;</pre><pre>&lt;/div&gt;</pre><pre>);</pre><pre>}</pre><pre>export default App;</pre><p>Now that we are able to interact with our contract on the blockchain, we will now write a function to get the current number from the state and set a new number by changing the state</p><p>Since we have to change state in React, import <strong><em>useState</em></strong> from <strong><em>react</em></strong></p><pre>import {useState} from &quot;react&quot;;</pre><p>Then we will declare in inside the function</p><pre>const [number, setNewNumber] = useState();</pre><p>Now we will create a function of getting the number from the contract</p><pre>// Function that gets number from the smart contract</pre><pre>async function getNumber() {</pre><pre>try {</pre><pre>const getStateNumber = await contract.methods.getNumber().call();</pre><pre>setNewNumber(getStateNumber);</pre><pre>} catch (error) {</pre><pre>console.log(&quot;Error:&quot;, error);</pre><pre>}</pre><pre>}</pre><p>We can get the value of the number stored in state from our contract by using the <strong><em>methods</em></strong> property of <strong><em>Contract</em></strong>, then the <strong><em>getNumber()</em></strong> function in our smart contract and finally using <strong><em>.call()</em></strong> to retrieve the number stored in the state variable</p><p>Now that we are able to retrieve the number set in state from the blockchain, let’s now write a function to change the state of number variable with a setter function</p><pre>async function changeNumber() {</pre><pre>// Assign array of accounts into getAccount variable</pre><pre>let getAccount = await web3.eth.getAccounts();</pre><pre>// Calling setNumber function and using first account to send transaction</pre><pre>await contract.methods.setNumber(number).send({ from: getAccount[0] });</pre><pre>// Resets input and h3 to blank</pre><pre>setNewNumber(&quot;&quot;);</pre><pre>}</pre><p>We get the accounts from Hardhat node using the <strong><em>getAccounts()</em></strong> method from Web3.js and then assign it a variable. Then using <strong><em>contract.methods</em></strong> similar to our <strong><em>getNumber()</em></strong> function, we will use it to call our <strong><em>setNumber()</em></strong> function from our smart contract from the blockchain and pass in the new number that the user will input. Then we will use the <strong><em>send()</em></strong> method and pass in the account we want to transact from.</p><p>The code should look like this…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fed066a36dcfd3fa4fc2847ab48e609/href">https://medium.com/media/6fed066a36dcfd3fa4fc2847ab48e609/href</a></iframe><p>Finally we will implement the functions and update the state on our page with the following in the <strong><em>return</em></strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65f4ed1ff0d70e722f60253c2687caf5/href">https://medium.com/media/65f4ed1ff0d70e722f60253c2687caf5/href</a></iframe><p>And the final code should look like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a2b44af3e019d056f8ed9e3f0aa0095/href">https://medium.com/media/0a2b44af3e019d056f8ed9e3f0aa0095/href</a></iframe><p>Now experiment by setting the number and then getting them. You should also notice the funds in the first account balance lower each time the number is set to pay for the transaction fee.</p><p>This concludes this article series that look at how Truffle and Hardhat is used to develop, deploy and interact with a smart contract.</p><p>Thanks for going on this journey together and stay tuned for more articles on blockchain, smart contracts and much more!</p><blockquote>Join Coinmonks <a href="https://t.me/coincodecap">Telegram Channel</a> and <a href="https://www.youtube.com/c/coinmonks/videos">Youtube Channel</a> learn about crypto trading and investing</blockquote><h4>Also, Read</h4><ul><li><a href="https://blog.coincodecap.com/p2p-crypto-exchanges-in-india">Best P2P Crypto Exchanges in India</a> | <a href="https://blog.coincodecap.com/baby-shiba-inu-wallets">Shiba Inu Wallets</a></li><li><a href="https://blog.coincodecap.com/crypto-affiliate-programs">Top 8 Crypto Affiliate Programs</a> | <a href="https://blog.coincodecap.com/etoro-vs-coinbase">eToro vs Coinbase</a></li><li><a href="https://blog.coincodecap.com/best-ethereum-wallets">Best Ethereum Wallets</a> | <a href="https://blog.coincodecap.com/telegram-crypto-bots">Cryptocurrency Bots on Telegram</a></li><li><a href="https://blog.coincodecap.com/leveraged-token-exchanges">Best Exchanges to Trade Leveraged Tokens</a></li><li><a href="https://blog.coincodecap.com/ascendex-staking">AscendEx Staking</a> | <a href="https://blog.coincodecap.com/bot-ocean-review">Bot Ocean Review</a> | <a href="https://blog.coincodecap.com/bitcoin-wallets-india">Best Bitcoin Wallets</a></li><li><a href="https://blog.coincodecap.com/bitget-review">Bitget Review</a> | <a href="https://blog.coincodecap.com/gemini-vs-blockfi">Gemini vs BlockFi</a> | <a href="https://blog.coincodecap.com/okex-futures-trading">OKEx Futures Trading</a></li><li><a href="https://blog.coincodecap.com/crypto-trading-bots-in-the-us">Best Crypto Trading Bots in the US</a> | <a href="https://blog.coincodecap.com/changelly-review">Changelly Review</a></li><li><a href="https://blog.coincodecap.com/crypto-arbitrage-in-india">Earn Passive Income Using Crypto Arbitrage In India</a></li><li><a href="https://blog.coincodecap.com/huobi-review">Huobi Review</a> | <a href="https://blog.coincodecap.com/okex-margin-trading">OKEx Margin Trading</a> | <a href="https://blog.coincodecap.com/futures-trading">Futures Trading</a></li><li><a href="https://blog.coincodecap.com/sparrow-exchange-review">Sparrow Exchange Review</a> | <a href="https://blog.coincodecap.com/nash-exchange-review">Nash Exchange Review</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d66dbc2c3c3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/project-setup-using-hardhat-truffle-part-5-2d66dbc2c3c3">Project Setup Using Hardhat &amp; Truffle — part 5</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Setup Using Hardhat & Truffle — part 4]]></title>
            <link>https://medium.com/coinmonks/project-setup-using-hardhat-truffle-part-4-9d2f55842be2?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d2f55842be2</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Wed, 15 Dec 2021 20:54:20 GMT</pubDate>
            <atom:updated>2022-01-07T15:25:40.433Z</atom:updated>
            <content:encoded><![CDATA[<h3>Project Setup Using Hardhat &amp; Truffle — part 4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n7eBCSDKctM0fMPK" /><figcaption>Photo by <a href="https://unsplash.com/@clark_fransa?utm_source=medium&amp;utm_medium=referral">Arnold Francisca</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Now that we have a smart contract, let’s deploy it to the blockchain</p><h3>Deployment on Truffle</h3><ul><li>In the terminal make sure we are in the truffle-example directory</li></ul><pre>cd truffle-example</pre><p>Before we can deploy our contract, we first have to add a new file under the migrations directory</p><p>Create a new file under the migrations directory and prefix the name of the file with <strong><em>“ 2_”</em> </strong>and name it <strong><em>2_NumberChanger.js</em></strong></p><ul><li>Inside<strong><em> 2_NumberChanger.js </em></strong>we will write the following script</li></ul><pre>const NumberChanger = artifacts.require(“NumberChanger”);<br>module.exports = function (deployer){ deployer.deploy(NumberChanger);<br>}</pre><p>We defined a variable called NumberChanger, but this can be any name you wish. Inside the variable, we call the <strong><em>artifacts.require</em></strong> method and pass in the name of our contract to interact with(not the name of the file), which in this case is also called<strong><em> ”NumberChanger”</em></strong></p><p>Afterwards, we export the function that would deploy the contract</p><blockquote>To learn more about how migrations work, go here <a href="https://trufflesuite.com/docs/truffle/getting-started/running-migrations#migration-files"><strong>Truffle Migration</strong></a></blockquote><p>Now that we are setup, lets deploy our contract, run the following in the terminal</p><pre>truffle compile</pre><p>And you should get the following results</p><pre>Compiling your contracts...</pre><pre>===========================</pre><pre>✔ Fetching solc version list from solc-bin. Attempt #1</pre><pre>&gt; Compiling ./contracts/Migrations.sol</pre><pre>&gt; Compiling ./contracts/NumberChanger.sol</pre><pre>&gt; Artifacts written to /Users/Desktop/Examples/truffle-example/build/contracts</pre><pre>&gt; Compiled successfully using:</pre><pre>- solc: 0.8.10+commit.fc410830.Emscripten.clang</pre><p>Once compiled, there should be a folder created called <strong><em>build</em></strong></p><p>This is where your contracts ABI is so that the front end can interact with it and the byte code is create for the EVM</p><p>Now that we have compiled our contracts, we can deploy it. For this example, we will deploy it to the localnet, Ganache.</p><p>First in the terminal, run the following command</p><pre>ganache-cli</pre><p>You should now see the following:</p><pre>Ganache CLI v6.12.2 (ganache-core: 2.13.2)</pre><pre>Available Accounts</pre><pre>==================</pre><pre>(0) 0x735d731D1B90eBFD8B35E550e7430282c98133eC (100 ETH)</pre><pre>(1) 0x59dc305ac3564D0aF51b770311F182890023ed73 (100 ETH)</pre><pre>(2) 0xb8a3fAC0eeD31dFF5E5A641a3278DC34afbFb35C (100 ETH)</pre><pre>(3) 0xC703D178A5F529186F035bf83E7EC4155951e537 (100 ETH)</pre><pre>(4) 0x8951B99e2fA2e5E721552d2091Ac922A140581A7 (100 ETH)</pre><pre>(5) 0x32919628CFCE86CcA027C09FabAe15643Ef6DEd2 (100 ETH)</pre><pre>(6) 0x3ae65932Ee15a270B8876845b5Cf6D23A4ee801E (100 ETH)</pre><pre>(7) 0xC429c4836504aF3Aa4b687163c9be108Fa3d35E4 (100 ETH)</pre><pre>(8) 0x7a9026b25Ceb30A0934384b354a53690c889FCfd (100 ETH)</pre><pre>(9) 0xd8F267534a42B91B8469127695c200E571a8c2F4 (100 ETH)</pre><pre>Private Keys<br>==================</pre><pre>(0) 0x7ab485a29412a9d4f466778d2d1de37c19fc1c10217e5bc10153af185541c445</pre><pre>(1) 0xc9fc3d2e11d0701dc52820187ad830f0f0b7cfc77365a8e1b8df7f38a3df2d90</pre><pre>(2) 0x09a2d80b06649bafe479d7f6610e41df6b5e77420aaa0d45cef9bb09016def90</pre><pre>(3) 0x54e49af326e58a98b831acf00ce8799f2cd23f470b382c5b184397b23450f18d</pre><pre>(4) 0x952d1e27ef8289a5988c89ea9096c694e2f376356972d73388fe3a48fd201b56</pre><pre>(5) 0x96ff3b0f11c396e4eb696b325fff8aeca0899bae5285c15a2096e503583edf68</pre><pre>(6) 0xd9b0ef3b02245d05588295836040df476c0298d1f33291e55556a874cabbccf3</pre><pre>(7) 0x4b2899ed136d6bff17f352a2aa6c2eb162ba183861dfb28487540c473b91f992</pre><pre>(8) 0x75fa379cd3b1e925849587af471e7000fe36d63496720147c8ceb13ca70d2872</pre><pre>(9) 0x907a9ee73f5fa3d3a79565106236f57687dc710c6e7a3bed97256ea494bb0b32</pre><pre>HD Wallet</pre><pre>==================</pre><pre>Mnemonic:      just always youth crew song dust frost virtual program amused scene cash</pre><pre>Base HD Path:  m/44&#39;/60&#39;/0&#39;/0/{account_index}</pre><pre>Gas Price</pre><pre>==================</pre><pre>20000000000</pre><pre>Gas Limit</pre><pre>==================</pre><pre>6721975</pre><pre>Call Gas Limit</pre><pre>==================</pre><pre>9007199254740991</pre><p>Now that we have our local blockchain running, we can now deploy our contract</p><p>Running the following code in the terminal and you should get the following result</p><pre>truffle migrate</pre><p><strong><em>truffle migrate </em></strong>is similar to <strong><em>truffle deploy</em></strong> You can find out more information on this topic here <a href="https://trufflesuite.com/docs/truffle/getting-started/running-migrations#migration-files"><strong><em>Truffle Migration</em></strong></a></p><pre>Compiling your contracts...</pre><pre>===========================</pre><pre>✔ Fetching solc version list from solc-bin. Attempt #1</pre><pre>&gt; Compiling ./contracts/Migrations.sol</pre><pre>&gt; Compiling ./contracts/NumberChanger.sol</pre><pre>&gt; Artifacts written to /Users/Desktop/Examples/truffle-example/build/contracts</pre><pre>&gt; Compiled successfully using:</pre><pre>- solc: 0.8.10+commit.fc410830.Emscripten.clang</pre><pre>Starting migrations...</pre><pre>======================</pre><pre>&gt; Network name:    &#39;development&#39;</pre><pre>&gt; Network id:      1639592180037</pre><pre>&gt; Block gas limit: 6721975 (0x6691b7)</pre><pre>1_initial_migration.js</pre><pre>======================</pre><pre>Deploying &#39;Migrations&#39;</pre><pre>----------------------</pre><pre>&gt; transaction hash:    0x41f9ad193605295c1424325c13c6f36e41ddfebd9836605542e8ff47af33e929</pre><pre>&gt; Blocks: 0            Seconds: 0</pre><pre>&gt; contract address:    0x01Dd5F52EC31A26C51D4EB42f0A448d863F342e0</pre><pre>&gt; block number:        21</pre><pre>&gt; block timestamp:     1639598127</pre><pre>&gt; account:             0x735d731D1B90eBFD8B35E550e7430282c98133eC</pre><pre>&gt; balance:             99.95056962</pre><pre>&gt; gas used:            248854 (0x3cc16)</pre><pre>&gt; gas price:           20 gwei</pre><pre>&gt; value sent:          0 ETH</pre><pre>&gt; total cost:          0.00497708 ETH</pre><pre>&gt; Saving migration to chain.</pre><pre>&gt; Saving artifacts</pre><pre>-------------------------------------</pre><pre>&gt; Total cost:          0.00497708 ETH</pre><pre>2_NumberChanger.js</pre><pre>==================</pre><pre>Deploying &#39;NumberChanger&#39;</pre><pre>-------------------------</pre><pre>&gt; transaction hash:    0x8aa0925fd1df6669566f89c4751e44b8fb905ca07618392e216f3223609dda9e</pre><pre>&gt; Blocks: 0            Seconds: 0</pre><pre>&gt; contract address:    0x2CdfF21817CEe737eBeB8fAd13af0f0964A1D907</pre><pre>&gt; block number:        23</pre><pre>&gt; block timestamp:     1639598127</pre><pre>&gt; account:             0x735d731D1B90eBFD8B35E550e7430282c98133eC</pre><pre>&gt; balance:             99.9472063</pre><pre>&gt; gas used:            125653 (0x1ead5)</pre><pre>&gt; gas price:           20 gwei</pre><pre>&gt; value sent:          0 ETH</pre><pre>&gt; total cost:          0.00251306 ETH</pre><pre>&gt; Saving migration to chain.</pre><pre>&gt; Saving artifacts</pre><pre>-------------------------------------</pre><pre>&gt; Total cost:          0.00251306 ETH</pre><pre>Summary</pre><pre>=======</pre><pre>&gt; Total deployments:   2</pre><pre>&gt; Final cost:          0.00749014 ETH</pre><p>You can see that <strong><em>truffle migrate</em></strong> compiles the contract and the deploys it. You can just use <strong><em>truffle migrate</em></strong> to compile and deploy your contract with one command</p><p>The contract is now deployed, can you can see the contact addresses</p><p>One last thing is to move the <strong><em>build</em></strong> folder. By default, it will be created in the root directory, but since we will be interacting with in from the front end with React, it should be located in the <strong><em>src </em></strong>folder.</p><p>In the <strong><em>truffle-config.js</em></strong> file, add the following code before <strong><em>module.exports</em></strong></p><pre>const path = require(&quot;path&quot;)</pre><p>place the following code under the <strong><em>module.exports</em></strong></p><pre>contracts_build_directory: path.join(__dirname, &quot;src/build&quot;),</pre><p>The result should look like the following:</p><pre>const path = require(&quot;path&quot;);</pre><pre>module.exports = {</pre><pre>contracts_build_directory: path.join(__dirname, &quot;src/build&quot;),</pre><pre>networks: {</pre><pre>development: {</pre><pre>host: &quot;127.0.0.1&quot;,</pre><pre>port: 8545,</pre><pre>network_id: &quot;*&quot;,</pre><pre>},</pre><pre>},</pre><pre>compilers: {</pre><pre>solc: {</pre><pre>version: &quot;pragma&quot;,</pre><pre>},</pre><pre>},</pre><pre>};</pre><p>Now when we redeploy our contract, the build folder should be created inside the <strong><em>src</em></strong> folder</p><h3>Deployment on Hardhat</h3><p>In the terminal make sure we are in the <strong><em>hardhat-example</em></strong> directory</p><pre>cd hardhat-example</pre><p>Before we can deploy our contract, we first have to add some code for hardhat to deploy our contract</p><p>Go to the scripts folder and rename the file <strong><em>sample-script.js</em></strong> to <strong><em>deploy.js</em></strong></p><p>Next, under the line: console.log(“Greeter deployed to:”, greeter.address);, type the following code:</p><pre>const NumberChanger = await hre.ethers.getContractFactory(&quot;NumberChanger&quot;);</pre><pre>const numberChanger = await NumberChanger.deploy();</pre><pre>await numberChanger.deployed();</pre><pre>console.log(&quot;Number deployed to:&quot;, numberChanger.address);</pre><p>What this code does is create a new variable that will take the NumberChanger contract and deploy it. Once the contract is deployed, it will log out in the terminal the address of the deployed NumberChanger contract.</p><blockquote>In Hardhat, you can put all the contracts to be compiled and deployed in the same file, which is located in the scripts folder.</blockquote><p>The code should look like the following with the default Greeter contract provided by Hardhat.</p><pre>const hre = require(&quot;hardhat&quot;);</pre><pre>async function main() {</pre><pre>const Greeter = await hre.ethers.getContractFactory(&quot;Greeter&quot;);</pre><pre>const greeter = await Greeter.deploy(&quot;Hello, Hardhat!&quot;);</pre><pre>await greeter.deployed();</pre><pre>console.log(&quot;Greeter deployed to:&quot;, greeter.address);</pre><pre>const NumberChanger = await hre.ethers.getContractFactory(&quot;NumberChanger&quot;);</pre><pre>const numberChanger = await NumberChanger.deploy();</pre><pre>await numberChanger.deployed();</pre><pre>console.log(&quot;Number deployed to:&quot;, numberChanger.address);</pre><pre>}</pre><pre>main()</pre><pre>.then(() =&gt; process.exit(0))</pre><pre>.catch((error) =&gt; {</pre><pre>console.error(error);</pre><pre>process.exit(1);</pre><pre>});</pre><p>Run the following in the terminal</p><pre>npx hardhat compile</pre><p>and should get the following output:</p><pre>Compiling 3 files with 0.8.0</pre><pre>Compilation finished successfully</pre><p>Once compiled, there should be a folder created called <strong><em>artifacts</em></strong></p><p>This is where your contracts ABI is so that the front end can interact with it and the byte code is create for the EVM</p><p>Now that we have compiled our contracts, we can deploy it. For this example, we will deploy it to the localnet provided by Hardhat</p><blockquote>To specify the network to deploy to, use the following command in the terminal <strong><em>npx hardhat run scripts/deploy.js — network &lt;network name&gt;</em></strong></blockquote><p>Run the following command in the terminal:</p><pre>npx hardhat run scripts/deploy.js</pre><p>You should now see the following output:</p><pre>Deploying a Greeter with greeting: Hello, Hardhat!</pre><pre>Greeter deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3</pre><pre>Number deployed to: 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512</pre><p>Now we are given the address to our contracts.</p><p>One last thing is to move the artifacts folder. By default, it will be created in the root directory, but since we will be interacting with in from the front end with React, it should be located in the <strong><em>src</em></strong> folder.</p><p>In the<strong><em> hardhat-config.js file</em></strong>, place the following code under the where the version of the solidity compiler version is declared.</p><pre>paths: {</pre><pre>artifacts: &#39;./src/artifacts&#39;,</pre><pre>},</pre><p>The code should look like the following:</p><pre>module.exports = {</pre><pre>networks: {</pre><pre>hardhat: {</pre><pre>chainId: 1337</pre><pre>},</pre><pre>},</pre><pre>solidity: &quot;0.8.0&quot;,</pre><pre>paths: {</pre><pre>artifacts: &#39;./src/artifacts&#39;,</pre><pre>},</pre><pre>};</pre><p>Now that we set the path, delete the artifacts folder in the root directory and redeploy it with <strong><em>npx hardhat run scripts/deploy.js</em></strong> and it should show up in the <strong><em>src</em></strong> folder.</p><p>Finally we will run a local blockchain with the following command that Hardhat provides</p><pre>npx harhat node</pre><p>This creates a list of 20 accounts with their private keys and is pre-funded with test Ether.</p><pre>Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/</pre><pre>Accounts</pre><pre>========</pre><pre>Account #0: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 (10000 ETH)</pre><pre>Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80</pre><pre>Account #1: 0x70997970c51812dc3a010c7d01b50e0d17dc79c8 (10000 ETH)</pre><pre>Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d</pre><pre>Account #2: 0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc (10000 ETH)</pre><pre>Private Key: 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a</pre><pre>Account #3: 0x90f79bf6eb2c4f870365e785982e1f101e93b906 (10000 ETH)</pre><pre>Private Key: 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6</pre><pre>Account #4: 0x15d34aaf54267db7d7c367839aaf71a00a2c6a65 (10000 ETH)</pre><pre>Private Key: 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a</pre><pre>Account #5: 0x9965507d1a55bcc2695c58ba16fb37d819b0a4dc (10000 ETH)</pre><pre>Private Key: 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba</pre><pre>Account #6: 0x976ea74026e726554db657fa54763abd0c3a0aa9 (10000 ETH)</pre><pre>Private Key: 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e</pre><pre>Account #7: 0x14dc79964da2c08b23698b3d3cc7ca32193d9955 (10000 ETH)</pre><pre>Private Key: 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356</pre><pre>Account #8: 0x23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f (10000 ETH)</pre><pre>Private Key: 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97</pre><pre>Account #9: 0xa0ee7a142d267c1f36714e4a8f75612f20a79720 (10000 ETH)</pre><pre>Private Key: 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6</pre><pre>Account #10: 0xbcd4042de499d14e55001ccbb24a551f3b954096 (10000 ETH)</pre><pre>Private Key: 0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897</pre><pre>Account #11: 0x71be63f3384f5fb98995898a86b02fb2426c5788 (10000 ETH)</pre><pre>Private Key: 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82</pre><pre>Account #12: 0xfabb0ac9d68b0b445fb7357272ff202c5651694a (10000 ETH)</pre><pre>Private Key: 0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1</pre><pre>Account #13: 0x1cbd3b2770909d4e10f157cabc84c7264073c9ec (10000 ETH)</pre><pre>Private Key: 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd</pre><pre>Account #14: 0xdf3e18d64bc6a983f673ab319ccae4f1a57c7097 (10000 ETH)</pre><pre>Private Key: 0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa</pre><pre>Account #15: 0xcd3b766ccdd6ae721141f452c550ca635964ce71 (10000 ETH)</pre><pre>Private Key: 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61</pre><pre>Account #16: 0x2546bcd3c84621e976d8185a91a922ae77ecec30 (10000 ETH)</pre><pre>Private Key: 0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0</pre><pre>Account #17: 0xbda5747bfd65f08deb54cb465eb87d40e51b197e (10000 ETH)</pre><pre>Private Key: 0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd</pre><pre>Account #18: 0xdd2fd4581271e230360230f9337d5c0430bf44c0 (10000 ETH)</pre><pre>Private Key: 0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0</pre><pre>Account #19: 0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199 (10000 ETH)</pre><pre>Private Key: 0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e</pre><h4>In part 5, we will build a simple front end in react and interact with our contract.</h4><blockquote>Join Coinmonks <a href="https://t.me/coincodecap">Telegram Channel</a> and <a href="https://www.youtube.com/c/coinmonks/videos">Youtube Channel</a> learn about crypto trading and investing</blockquote><h4>Also, Read</h4><ul><li><a href="https://blog.coincodecap.com/crypto-tax-india">Crypto Tax in India</a> | <a href="https://blog.coincodecap.com/altfins-review">altFINS Review</a> | <a href="https://medium.com/coinmonks/prokey-review-26611173c13c">Prokey Review</a></li><li><a href="https://blog.coincodecap.com/blockfi-vs-coinbase">Blockfi vs Coinbase</a> | <a href="https://blog.coincodecap.com/bitkan-review">BitKan Review</a> | <a href="https://blog.coincodecap.com/bexplus-review">Bexplus Review</a></li><li><a href="https://blog.coincodecap.com/crypto-exchanges-in-south-africa">Crypto Exchanges In South Africa</a> | <a href="https://blog.coincodecap.com/bitmex-crypto-signals">BitMEX Crypto Signals</a></li><li><a href="https://blog.coincodecap.com/moonxbt-copy-trading">MoonXBT Copy Trading</a> | <a href="https://blog.coincodecap.com/crypto-wallets-in-uae">Crypto Wallets in UAE</a></li><li><a href="https://blog.coincodecap.com/remitano-review">Remitano Review</a> | <a href="https://blog.coincodecap.com/1inch">Guide to 1inch Protocol</a></li><li><a href="https://blog.coincodecap.com/itop-vpn-review">iTop VPN Review</a> | <a href="https://blog.coincodecap.com/mandala-exchange-review">Mandala Exchange Review</a></li><li><a href="https://blog.coincodecap.com/best-telegram-channels">40 Best Telegram Channels</a> | <a href="https://blog.coincodecap.com/hi-dollar-review">Hi Dollar Review</a></li><li><a href="https://blog.coincodecap.com/fold-app-review">Fold App Review</a> | <a href="https://medium.com/coinmonks/stealthex-review-396c67309988">StealthEX Review</a> | <a href="https://blog.coincodecap.com/stormgain-review">Stormgain Review</a></li><li><a href="https://blog.coincodecap.com/buy-pancakeswap">Buy PancakeSwap (CAKE)</a> | <a href="https://medium.com/coinmonks/coinswitch-kuber-review-1a8dc5c7a739">Coinswitch Kuber Review</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d2f55842be2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/project-setup-using-hardhat-truffle-part-4-9d2f55842be2">Project Setup Using Hardhat &amp; Truffle — part 4</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Setup Using Hardhat & Truffle — part 3]]></title>
            <link>https://medium.com/coinmonks/project-setup-using-hardhat-truffle-part-3-724ab0d2a1fe?source=rss-8daf9fad9874------2</link>
            <guid isPermaLink="false">https://medium.com/p/724ab0d2a1fe</guid>
            <category><![CDATA[dapps]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[truffle]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Shih-Yu Hwang]]></dc:creator>
            <pubDate>Fri, 03 Dec 2021 16:32:08 GMT</pubDate>
            <atom:updated>2021-12-16T16:34:51.331Z</atom:updated>
            <content:encoded><![CDATA[<h3>Project Setup Using Hardhat &amp; Truffle — part 3</h3><figure><img alt="Laptop open on a desk" src="https://cdn-images-1.medium.com/max/640/1*TPR5JP0_hjyGvfVXrSmuWw.jpeg" /></figure><p>Now we will write a simple smart contract and deploy it to our local blockchain</p><h3><strong>Writing the smart contract</strong></h3><blockquote>We can ignore the existing contract for now but feel free to explore them</blockquote><p>For both Truffle and Hardhat, we can create a new file inside the contract folder</p><blockquote>Solidity is the language that will be used for our example. More information about it can be found <a href="https://docs.soliditylang.org/en/v0.8.7/">HERE</a></blockquote><ul><li>Name it</li></ul><pre>NumberChanger.sol</pre><ul><li>Declare the SPDX-License with it being commented out</li></ul><pre>// SPDX-License-Identifier: MIT</pre><ul><li>Define the version of Solidity the contract will be complied in, we will set it to the version to be the same as in our config file</li></ul><blockquote>This allows it to be compiled with version 0.8.6 or higher</blockquote><pre>pragma solidity ^0.8.6;</pre><ul><li>Write our contract by first declaring it and giving it the same name as our file name</li></ul><pre>/ SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;<br></pre><pre>contract NumberChanger {</pre><pre>}</pre><ul><li>Declare a state variable called number</li></ul><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;<br></pre><pre>contract NumberChanger {</pre><pre>uint256 number;</pre><pre>}</pre><ul><li>Create a function that will retrieve the number stored in the state variable</li></ul><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;</pre><pre>contract NumberChanger {</pre><pre>uint256 number;</pre><pre>function getNumber() public views returns(uint256) {</pre><pre>return number;</pre><pre>  }</pre><pre>}</pre><ul><li>Create a function that updates the number in state variable</li></ul><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;</pre><pre>contract NumberChanger {</pre><pre>uint256 number;</pre><pre>function getNumber() public views returns(uint256) {</pre><pre>return number;</pre><pre>}</pre><pre>function setNumber(uint256 _number) public {</pre><pre>number = _number;</pre><pre> }</pre><pre>}</pre><p>We now have written a smart contract that allows the number to be stored and updated on the blockchain</p><h3><strong>Hardhat</strong></h3><p>Hardhat allows the option to console log in Solidity, in order to do so</p><ul><li>Import hardhat/console.sol after the version of Solidity has been declared</li></ul><pre>import &quot;hardhat/console.sol&quot;</pre><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;</pre><pre>import &quot;hardhat/console.sol&quot;</pre><ul><li>Add it to where you would like to see an output</li></ul><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;</pre><pre>import &quot;hardhat/console.sol&quot;;</pre><pre>contract NumberChanger {</pre><pre>uint256 number;</pre><pre>function getNumber() public view returns(uint256) {</pre><pre>return number;</pre><pre>}</pre><pre>function setNumber(uint256 _number) public {</pre><pre>number = _number;</pre><pre>console.log(number)</pre><pre> }</pre><pre>}</pre><blockquote>The import of hardhat/console.sol and use of console.log is optional only if you are using Hardhat</blockquote><p>The finished contract should look like this</p><pre>// SPDX-License-Identifier: MIT</pre><pre>pragma solidity ^0.8.6;</pre><pre>contract NumberChanger {</pre><pre>uint256 number;</pre><pre>function getNumber() public view returns(uint256) {</pre><pre>return number;</pre><pre>}</pre><pre>function setNumber(uint256 _number) public {</pre><pre>number = _number;</pre><pre> }</pre><pre>}</pre><h4><strong>In part 4 we will deploy our contract to the local blockchain. </strong><a href="https://medium.com/@shihyuhwang/9d2f55842be2"><strong>Click here for part 4</strong></a><strong>.</strong></h4><blockquote>Join Coinmonks <a href="https://t.me/coincodecap">Telegram Channel</a> and <a href="https://www.youtube.com/c/coinmonks/videos">Youtube Channel</a> learn about crypto trading and investing</blockquote><h4>Also, Read</h4><ul><li><a href="https://blog.coincodecap.com/crypto-exchange-africa">Best Crypto Exchanges in Africa</a> | <a href="https://blog.coincodecap.com/hoo-exchange-review">Hoo Exchange Review</a></li><li><a href="https://blog.coincodecap.com/etoro-robinhood">eToro vs Robinhood</a> | <a href="https://blog.coincodecap.com/bybit-bityard-moonxbt">MoonXBT vs Bybit vs Bityard</a></li><li><a href="https://blog.coincodecap.com/trading-signal">What are the Trading Signals?</a> | <a href="https://blog.coincodecap.com/bitstamp-coinbase">Bitstamp vs Coinbase</a></li><li><a href="https://blog.coincodecap.com/profitfarmers-review">ProfitFarmers Review</a> | <a href="https://blog.coincodecap.com/cornix-trading-bot">How to use Cornix Trading Bot</a></li><li><a href="https://blog.coincodecap.com/buy-domain-on-unstoppable-domains">How to Buy Domain Name on Unstoppable Domains?</a></li><li><a href="https://blog.coincodecap.com/crypto-tax-india">Crypto Tax in India</a> | <a href="https://blog.coincodecap.com/altfins-review">altFINS Review</a> | <a href="https://medium.com/coinmonks/prokey-review-26611173c13c">Prokey Review</a></li><li><a href="https://blog.coincodecap.com/blockfi-vs-coinbase">Blockfi vs Coinbase</a> | <a href="https://blog.coincodecap.com/bitkan-review">BitKan Review</a> | <a href="https://blog.coincodecap.com/bexplus-review">Bexplus Review</a></li><li><a href="https://blog.coincodecap.com/crypto-exchanges-in-south-africa">Crypto Exchanges In South Africa</a> | <a href="https://blog.coincodecap.com/bitmex-crypto-signals">BitMEX Crypto Signals</a></li><li><a href="https://blog.coincodecap.com/moonxbt-copy-trading">MoonXBT Copy Trading</a> | <a href="https://blog.coincodecap.com/crypto-wallets-in-uae">Crypto Wallets in UAE</a></li><li><a href="https://blog.coincodecap.com/remitano-review">Remitano Review</a> | <a href="https://blog.coincodecap.com/1inch">Guide to 1inch Protocol</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=724ab0d2a1fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/project-setup-using-hardhat-truffle-part-3-724ab0d2a1fe">Project Setup Using Hardhat &amp; Truffle — part 3</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>