<?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 Sumi Mudgil on Medium]]></title>
        <description><![CDATA[Stories by Sumi Mudgil on Medium]]></description>
        <link>https://medium.com/@sumimudgil?source=rss-43f668fa37a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xDjAR4Cs-Reb7_BC</url>
            <title>Stories by Sumi Mudgil on Medium</title>
            <link>https://medium.com/@sumimudgil?source=rss-43f668fa37a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 20:54:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sumimudgil/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[Integrating Your Smart Contract with the Frontend]]></title>
            <link>https://medium.com/alchemy-api/integrating-your-smart-contract-with-the-frontend-4e0302e449af?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e0302e449af</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Mon, 24 May 2021 18:33:27 GMT</pubDate>
            <atom:updated>2021-05-24T18:33:27.694Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this tutorial, we’ll teach you how to create a full stack dApp by connecting your Hello World smart contract to a React frontend using Metamask and Web3 tools.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fO3wgKil09knnFBG.png" /></figure><p>Prior to starting this tutorial, you’ll need to have finished part 1: <a href="https://medium.com/alchemy-api/hello-world-smart-contract-for-beginners-7a65cc4ae95f">creating and deploying a smart contract</a>, part 2: <a href="https://medium.com/alchemy-api/interacting-with-a-smart-contract-4a6bad3bc30">interacting with your smart contract</a>, and part 3:<a href="https://medium.com/alchemy-api/submitting-your-smart-contract-to-etherscan-3c72c99cc0de"> submitting your smart contract to Etherscan</a>.</p><p><em>Still haven’t written and deployed your own smart contract? Check out </em><a href="https://medium.com/alchemy-api/hello-world-smart-contract-for-beginners-7a65cc4ae95f"><em>this tutorial</em></a><em>. Don’t have an Alchemy account yet?</em><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:52c81d50-8654-4ea4-b8fc-ba8f8d575950"><em> Sign up for free</em></a><em>.</em></p><h3>Marrying Web2 &amp; Web3: connecting your smart contract to a frontend project</h3><p>🎉Woooo! You finally made it the last part of this tutorial series: creating a full stack decentralized application (dApp) by connecting your Hello World smart contract to a frontend project and interacting with it.</p><p>By the end of this tutorial, you&#39;ll know how to:</p><ul><li>Connect a Metamask wallet to your dApp project</li><li>Read data from your smart contract using the <a href="https://docs.alchemy.com/alchemy/documentation/alchemy-web3">Alchemy Web3</a> API</li><li>Sign Ethereum transactions using Metamask</li></ul><p>For this dApp, we&#39;ll be using <a href="https://reactjs.org/">React</a> as our frontend framework; however, it&#39;s important to note that we won&#39;t be spending much time breaking down its fundamentals, as we&#39;ll mostly be focusing on bringing Web3 functionality to our project.</p><p><strong>ℹ️ NOTE: </strong>As a prerequisite, you should have a beginner-level understanding of React—know how components, props, useState/useEffect, and basic function calling works. If you&#39;ve never heard of any of those terms before, we recommend that you check out this <a href="https://reactjs.org/tutorial/tutorial.html">Intro to React tutorial</a>. For the more visual learners, we highly recommend this awesome Net Ninja <a href="https://www.youtube.com/playlist?list=PL4cUxeGkcC9gZD-Tvwfod2gaISzfRiP9d">Full Modern React Tutorial</a> video series.</p><p>What are we here for? Let&#39;s get started! 😎</p><h3>Step 1: Clone the starter files</h3><p>First, go to the <a href="https://github.com/alchemyplatform/hello-world-part-four-tutorial">hello-world-part-four github repository</a> to get the starter files for this project. Clone this repository into your local environment.</p><p><strong>ℹ️ NOTE: </strong>Don&#39;t know how to clone a repository? Check out <a href="https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository">this guide</a> from Github.</p><p>When you open this cloned hello-world-part-four repository, you&#39;ll notice that it contains two folders: starter-files and completed.</p><ul><li>starter-files contains the starter files (essentially the React UI) for this project. In this tutorial, <strong>we will be working in this directory</strong>, as you learn how to bring this UI to life by connecting it to your Ethereum wallet and the Hello World smart contract that you published on Etherscan in <a href="https://docs.alchemy.com/alchemy/tutorials/hello-world-smart-contract/submitting-your-smart-contract-to-etherscan">Part 3</a>.</li><li>completed contains the entire completed tutorial and is there for you as a <strong>reference</strong> <strong>if you get stuck.</strong></li></ul><p>Next, open your copy of starter-files to your favorite code editor (at Alchemy, we we&#39;re big fans of <a href="https://code.visualstudio.com/download">VSCode</a>), and then navigate into your src folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zr-XeusmdAhJTu1V" /><figcaption>The “src” folder</figcaption></figure><p>All of the code we’ll write will live under the src folder. We&#39;ll be editing the HelloWorld.js component and the util/interact.js javascript files to give our project Web3 functionality.</p><h3>Step 2: Check out the starter files</h3><p>Before we start coding, it’s super important that we figure out what’s already provided for us in the starter files.</p><h4>Get your react project running</h4><p>Let’s start by running the React project in our browser. The beauty of React is that once we have our project running in our browser, any changes we save will be updated live in our browser.</p><p>To get the project running, navigate to the root directory of the starter-files folder, and the run npm install in your terminal to install the dependencies of the project:</p><pre>cd starter-files<br>npm install</pre><p>Once those have finished installing, run npm start in your terminal:</p><pre>npm start</pre><p>Doing so should open <a href="http://localhost:3000/">http://localhost:3000/</a> in your browser, where you’ll see the frontend for our project. It should consist of one field (a place to update the message stored in your smart contract), a “Connect Wallet” button, and an “Update” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eXKe0WvxP9vhb1t2" /><figcaption>What your UI should look like</figcaption></figure><p>If you try clicking “Connect Wallet” or “Update” buttons, you’ll notice that they don’t work — that’s because we still need to program their functionality! :)</p><h4>The HelloWorld.js component</h4><p><strong>ℹ️ NOTE:</strong> Make sure you’re in the starter-files folder and not the completed folder!</p><p>Let’s go back into the src folder in our editor and open the HelloWorld.js file. It&#39;s super important that we understand everything in this file, as it is the primary React component we will be working on.</p><p>At the top of our this file, you’ll notice we have several import statements that are necessary to get our project running, including the React library, useEffect and useState hooks, some items from the ./util/interact.js (we&#39;ll describe them in more details soon!), and the Alchemy logo. 🧙‍♂️</p><pre>/* HelloWorld.js*/</pre><pre>import React from “react”;<br>import { useEffect, useState } from “react”;<br>import {<br> helloWorldContract,<br> connectWallet,<br> updateMessage,<br> loadCurrentMessage,<br> getCurrentWalletConnected,<br>} from “./util/interact.js”;</pre><pre>import alchemylogo from “./alchemylogo.svg”;</pre><p>Next, we have our state variables that we will update after specific events.</p><pre>/* HelloWorld.js*/</pre><pre>//State variables<br>const [walletAddress, setWallet] = useState(“”);<br>const [status, setStatus] = useState(“”);<br>const [message, setMessage] = useState(“No connection to the network.”);<br>const [newMessage, setNewMessage] = useState(“”);</pre><p>ℹ️ NOTE: Never heard of React state variables or state hooks? Check out <a href="https://reactjs.org/docs/hooks-state.html">these</a> docs.</p><p>Here’s what each of the variables represents:</p><ul><li>walletAddress - a string that stores the user&#39;s wallet address</li><li>status- a string that stores a helpful message that guides the user on how to interact with the dApp</li><li>message - a string that stores the current message in the smart contract</li><li>newMessage - a string that stores the new message that will be written to the smart contract</li></ul><p>After the state variables, you’ll see five un-implemented functions: useEffect ,addSmartContractListener, addWalletListener , connectWalletPressed, and onPublishedPressed. We&#39;ll explain what they do below:</p><pre>/* HelloWorld.js */</pre><pre>  //called only once<br>  useEffect(async () =&gt; { //TODO: implement<br>   <br>  }, []);</pre><pre>  function addSmartContractListener() { //TODO: implement<br>    <br>  }</pre><pre>  function addWalletListener() { //TODO: implement<br>    <br>  }<br>  <br>  const connectWalletPressed = async () =&gt; { //TODO: implement<br>   <br>  };<br>  <br>  const onUpdatePressed = async () =&gt; { //TODO: implement<br>   <br>  };</pre><ul><li><a href="https://reactjs.org/docs/hooks-effect.html">useEffect</a>- this is a React hook that is called after your component is rendered. Because it has an empty array [] prop passed into it (see line 4), it will only be called on the component&#39;s <em>first</em> render. Here we&#39;ll load the current message stored in our smart contract, call our smart contract and wallet listeners, and update our UI to reflect whether a wallet is already connected.</li><li>addSmartContractListener- this function sets up a listener that will watch for our HelloWorld contract&#39;s UpdatedMessages event and update our UI when the message is changed in our smart contract.</li><li>addWalletListener- this function sets up a listener that detects changes in the user&#39;s Metamask wallet state, such as when the user disconnects their wallet or switches addresses.</li><li>connectWalletPressed- this function will be called to connect the user&#39;s Metamask wallet to our dApp.</li><li>onUpdatePressed - this function will be called when the user wants to update the message stored in the smart contract.</li></ul><p>Near the end of this file, we have the UI of our component.</p><pre>/* HelloWorld.js */</pre><pre>//the UI of our component<br>return (<br>    &lt;div id=&quot;container&quot;&gt;<br>      &lt;img id=&quot;logo&quot; src={alchemylogo}&gt;&lt;/img&gt;<br>      &lt;button id=&quot;walletButton&quot; onClick={connectWalletPressed}&gt;<br>        {walletAddress.length &gt; 0 ? (<br>          &quot;Connected: &quot; +<br>          String(walletAddress).substring(0, 6) +<br>          &quot;...&quot; +<br>          String(walletAddress).substring(38)<br>        ) : (<br>          &lt;span&gt;Connect Wallet&lt;/span&gt;<br>        )}<br>      &lt;/button&gt;</pre><pre>&lt;h2 style={{ paddingTop: &quot;50px&quot; }}&gt;Current Message:&lt;/h2&gt;<br>      &lt;p&gt;{message}&lt;/p&gt;</pre><pre>&lt;h2 style={{ paddingTop: &quot;18px&quot; }}&gt;New Message:&lt;/h2&gt;</pre><pre>&lt;div&gt;<br>        &lt;input<br>          type=&quot;text&quot;<br>          placeholder=&quot;Update the message in your smart contract.&quot;<br>          onChange={(e) =&gt; setNewMessage(e.target.value)}<br>          value={newMessage}<br>        /&gt;<br>        &lt;p id=&quot;status&quot;&gt;{status}&lt;/p&gt;</pre><pre>&lt;button id=&quot;publishButton&quot; onClick={onUpdatePressed}&gt;<br>          Update<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );</pre><p>If you scan this code carefully, you’ll notice where we use our various state variables in our UI:</p><ul><li>On lines 6–12, if the user’s wallet is connected (i.e. walletAddress.length &gt; 0), we display a truncated version of the user walletAddress in the button with ID &quot;walletButton;&quot; otherwise it simply says &quot;Connect Wallet.&quot;</li><li>On line 17, we display the current message stored in the smart contract, which captured in the message string.</li><li>One lines 23–26, we use a <a href="https://reactjs.org/docs/forms.html#controlled-components">controlled component</a> to update our newMessage state variable when the input in the text field changes.</li></ul><p>In addition to our state variables, you’ll also see that connectWalletPressed and onPublishedPressed functions are called when the buttons with IDs publishButton and walletButton are clicked respectively.</p><p>Finally, let’s address where is this HelloWorld.js component added.</p><p>If you go to the App.js file, which is the main component in React that acts as a container for all other components, you&#39;ll see that our HelloWorld.js component is injected on line 7.</p><p>Last but not least, let’s check out one more file provided for you, the interact.js file.</p><h4>The interact.js file</h4><p>Because we want to prescribe to the <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">M-V-C</a> paradigm, we’ll want a separate file that contains all our functions to manage the logic, data, and rules of our dApp, and then be able to export those functions to our frontend (our HelloWorld.js component).</p><p>👆🏽This is the exact purpose of our interact.js file!</p><p>Navigate to the util folder in your src directory, and you&#39;ll notice we&#39;ve included a file called interact.js that will contain all of our smart contract interaction and wallet functions and variables.</p><pre>/* interact.js */</pre><pre>//export const helloWorldContract;</pre><pre>export const loadCurrentMessage = async () =&gt; {</pre><pre>};</pre><pre>export const connectWallet = async () =&gt; {</pre><pre>};</pre><pre>const getCurrentWalletConnected = async () =&gt; {</pre><pre>};</pre><pre>export const updateMessage = async (message) =&gt; {</pre><pre>};</pre><p>You’ll notice at the top of the file that we’ve commented out the helloWorldContract object. Later in this tutorial, we will uncomment this object and instantiate our smart contract in this variable, which we will then export into our HelloWorld.js component.</p><p>The three unimplemented functions after our helloWorldContract object do the following:</p><ul><li>loadCurrentMessage - this function handles the logic of loading the current message stored in the smart contract. It will make a <em>read</em> call to the Hello World smart contract using the <a href="https://github.com/alchemyplatform/alchemy-web3">Alchemy Web3 API</a>.</li><li>connectWallet - this function will connect the user&#39;s Metamask to our dApp.</li><li>getCurrentWalletConnected - this function will check if an Ethereum account is already connected to our dApp on page load and update our UI accordingly.</li><li>updateMessage - this function will update the message stored in the smart contract. It will make a <em>write</em> call to the Hello World smart contract, so the user&#39;s Metamask wallet will have to sign an Ethereum transaction to update the message.</li></ul><p>Now that we understand what we’re working with, let’s figure out how to read from our smart contract!</p><h3>Step 3: Read from your smart contract</h3><p>To read from your smart contract, you’ll need to successfully set up:</p><ul><li>An API connection to the Ethereum chain</li><li>A loaded instance of your smart contract</li><li>A function to call to your smart contract function</li><li>A listener to watch for updates when the data you’re reading from the smart contract changes</li></ul><p>This may sounds like a lot of steps, but don’t worry! We’ll walk you through how to do each of them step-by-step! :)</p><h4>Establish an API connection to the Ethereum chain</h4><p>So remember how in Part 2 of this tutorial, we used our <a href="https://medium.com/alchemy-api/interacting-with-a-smart-contract-4a6bad3bc30">Alchemy Web3 key to read from our smart contract</a>? You’ll also need an Alchemy Web3 key in your dApp to read from the chain.</p><p>If you don’t have it already, first install <a href="https://github.com/alchemyplatform/alchemy-web3">Alchemy Web3</a> by navigating to the root directory of your starter-files and running the following in your terminal:</p><pre>npm install @alch/alchemy-web3</pre><p><strong>ℹ️ NOTE:</strong> <a href="https://github.com/alchemyplatform/alchemy-web3">Alchemy Web3</a> is a wrapper around <a href="https://web3js.readthedocs.io/en/v1.2.9/">Web3.js</a>, providing enhanced API methods and other crucial benefits to make your life as a web3 developer easier. It is designed to require minimal configuration so you can start using it in your app right away!</p><p>Then, install the <a href="https://www.npmjs.com/package/dotenv">dotenv</a> package in your project directory, so we have a secure place to store our API key after we fetch it.</p><pre>npm install dotenv --save</pre><p>For our dApp, <strong>we’ll be using our Websockets API key</strong> instead of our HTML API key, as it will allow us to set up a listener that detects when the message stored in the smart contract changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*wOyCdTF-RHHptLkt" /><figcaption>Copy the websockets url</figcaption></figure><p>Once you have your API key, create a .env file in your root directory and add your Alchemy Websockets url to it. Afterwards, your .env file should look like so:</p><pre>REACT_APP_ALCHEMY_KEY = wss://eth-ropsten.ws.alchemyapi.io/v2/&lt;key&gt;</pre><p>Now, we’re ready to set up our Alchemy Web3 endpoint in our dApp! Let’s go back to our interact.js, which is nested inside our util folder and add the following code at the top of the file:</p><pre>/* interact.js */</pre><pre>require(&#39;dotenv&#39;).config();<br>const alchemyKey = process.env.REACT_APP_ALCHEMY_KEY;<br>const { createAlchemyWeb3 } = require(&quot;@alch/alchemy-web3&quot;);<br>const web3 = createAlchemyWeb3(alchemyKey);<br>//export const helloWorldContract;</pre><p>Above, we first imported the Alchemy key from our .env file and then passed our alchemyKey to createAlchemyWeb3 to establish our Alchemy Web3 endpoint.</p><p>With this endpoint ready, it’s time to load our smart contract!</p><h4>Loading your Hello World smart contract</h4><p>To load your Hello World smart contract, you’ll need its contract address and ABI, both of which can be found on Etherscan if you completed <a href="https://docs.alchemy.com/alchemy/tutorials/hello-world-smart-contract/submitting-your-smart-contract-to-etherscan">Part 3 of this tutorial.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/0*eMRbVpSRKArFwXkb" /><figcaption>How to get your contract ABI from Etherscan</figcaption></figure><p><strong>ℹ️ NOTE: </strong>If you skipped Part 3 of this tutorial, you can use the HelloWorld contract with address <a href="https://ropsten.etherscan.io/address/0x6f3f635a9762b47954229ea479b4541eaf402a6a#code">0x6f3f635A9762B47954229Ea479b4541eAF402A6A</a>. It’s ABI can be found <a href="https://ropsten.etherscan.io/address/0x6f3f635a9762b47954229ea479b4541eaf402a6a#code">here</a>.</p><p>A contract ABI is necessary for specifying which function a contract will invoke as well ensuring that the function will return data in the format you’re expecting. Once we’ve copied our contract ABI, let’s save it as a JSON file called contract-abi.json in your src directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WUUSzaULhsm6EFQx" /><figcaption>Your contract-abi.json should be stored in your src folder.</figcaption></figure><p>Armed with our contract address, ABI, and Alchemy Web3 endpoint, we can use the <a href="https://web3js.readthedocs.io/en/v1.2.0/web3-eth-contract.html?highlight=constructor#web3-eth-contract">contract method</a> to load an instance of our smart contract. Import your contract ABI into the interact.js file and add your contract address.</p><pre>/* interact.js */</pre><pre>const contractABI = require(&quot;../contract-abi.json&quot;);<br>const contractAddress = &quot;0x6f3f635A9762B47954229Ea479b4541eAF402A6A&quot;;</pre><p>We can now finally uncomment our helloWorldContract variable, and load the smart contract using our AlchemyWeb3 endpoint:</p><pre>/* interact.js */</pre><pre>export const helloWorldContract = new web3.eth.Contract(contractABI, contractAddress);</pre><p>To recap, the first 12 lines of your interact.js should now look like this:</p><pre>/* interact.js */</pre><pre>require(&#39;dotenv&#39;).config();<br>const alchemyKey = process.env.REACT_APP_ALCHEMY_KEY;<br>const { createAlchemyWeb3 } = require(&quot;@alch/alchemy-web3&quot;);<br>const web3 = createAlchemyWeb3(alchemyKey);</pre><pre>const contractABI = require(&#39;../contract-abi.json&#39;)<br>const contractAddress = &quot;0x6f3f635A9762B47954229Ea479b4541eAF402A6A&quot;;</pre><pre>export const helloWorldContract = new web3.eth.Contract(<br>contractABI,contractAddress);</pre><p>Now that we have our contract loaded, we can implement our loadCurrentMessage function!</p><h4>Implementing loadCurrentMessage in your interact.js file</h4><p>This function is super simple. Just like we do in <a href="https://docs.alchemy.com/alchemy/tutorials/hello-world-smart-contract/interacting-with-a-smart-contract#step-5-read-the-init-message">Part 2 of this tutorial series</a>, here we’re going make a simple async web3 call to read from our contract. Our function will return the message stored in the smart contract:</p><p>Update the loadCurrentMessage in your interact.js file to the following:</p><pre>/* interact.js */</pre><pre>export const loadCurrentMessage = async () =&gt; { <br>    const message = await helloWorldContract.methods.message().call(); <br>    return message;<br>};</pre><p>Since we want to display this smart contract in our UI, let’s update the useEffect function in our HelloWorld.js component to the following:</p><pre>/* HelloWorld.js */</pre><pre>//called only once<br>useEffect(async () =&gt; {<br>    const message = await loadCurrentMessage();<br>    setMessage(message);<br>}, []);</pre><p>Note, we only want our loadCurrentMessage to be called once during the component&#39;s first render. We&#39;ll soon implement addSmartContractListener to automatically update the UI after the message in the smart contract changes.</p><p>Before we dive into our listener, let’s check out what we have so far! Save your HelloWorld.js and interact.js files, and then go to <a href="http://localhost:3000/">http://localhost:3000/</a>​</p><p>You’ll notice that the current message no longer says “No connection to the network.” Instead it reflects the message stored in the smart contract. Sick!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ayfl6x2m9uDwhIbL" /><figcaption>Your UI should now reflect the message stored in the smart contract</figcaption></figure><p>Now speaking of that listener…</p><h4><strong>Implement</strong> addSmartContractListener</h4><p>If you think back to the HelloWorld.sol file we wrote in <a href="https://docs.alchemy.com/alchemy/tutorials/hello-world-smart-contract#step-10-write-our-contract">Part 1 of this tutorial series</a>, you&#39;ll recall that there is a smart contract event called UpdatedMessages that is emitted after our smart contract&#39;s update function is invoked.</p><p>The addSmartContractListener function is going to specifically listen for our Hello World smart contract&#39;s UpdatedMessages event, and update our UI to display the new message.</p><p>Modify addSmartContractListener to the following:</p><pre>/* Hello World.js */</pre><pre>function addSmartContractListener() {<br>    helloWorldContract.events.UpdatedMessages({}, (error, data) =&gt; {<br>      if (error) {<br>        setStatus(&quot;😥 &quot; + error.message);<br>      } else {<br>        setMessage(data.returnValues[1]);<br>        setNewMessage(&quot;&quot;);<br>        setStatus(&quot;🎉 Your message has been updated!&quot;);<br>      }<br>    });<br>  }</pre><p>Let’s break down what happens when the listener detects an event:</p><ul><li>If an error occurs when the event is emitted, it will be reflected in the UI via our status state variable.</li><li>Otherwise, we will use the data object returned. The data.returnValues is an array indexed at zero where the first element in the array stores the previous message and second element stores the updated one. Altogether, on a successful event we&#39;ll set our message string to the updated message, clear the newMessage string, and update our status state variable to reflect that a new message has been published on our smart contract.</li></ul><p>Finally, let’s call our listener in our useEffect function so it is initialized on the HelloWorld.js component&#39;s first render. Altogether, your useEffect function should look like this:</p><pre>/* HelloWorld.js */</pre><pre>useEffect(async () =&gt; {<br>    const message = await loadCurrentMessage();<br>    setMessage(message);<br>    addSmartContractListener();<br>}, []);</pre><p>Now that we’re able to read from our smart contract, it would be great to figure out how to write to it too! However, to write to our dApp, we must first have an Ethereum wallet connected to it.</p><p>So, next we’ll tackle setting up our Ethereum wallet (Metamask) and then connecting it to our dApp!</p><h3>Step 4: Set up your Ethereum wallet</h3><p>To write anything to the Ethereum chain, users must their sign transactions using their virtual wallet’s private keys. For this tutorial, we’ll use <a href="https://metamask.io/">Metamask</a>, a virtual wallet in the browser used to manage your Ethereum account address, as it makes this transaction signing super easy for the end-user.</p><p><strong>ℹ️ NOTE: </strong>If you want to understand more about how transactions on Ethereum work, check out <a href="https://ethereum.org/en/developers/docs/transactions/">this page</a> from the Ethereum foundation.</p><h4>Download Metamask</h4><p>You can download and create a Metamask account for free <a href="https://metamask.io/download.html">here</a>. When you are creating an account, or if you already have an account, make sure to switch over to the “Ropsten Test Network” in the upper right (so that we’re not dealing with real money).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/0*Rj733fuyr8EGdw6J" /><figcaption>Sample Metamask Wallet</figcaption></figure><h4>Add ether from a Faucet</h4><p>To sign a transaction on the Ethereum blockchain, we’ll need some fake Eth. To get Eth you can go to the <a href="https://faucet.ropsten.be/">Ropsten faucet</a> and enter your Ropsten account address, then click “Send Ropsten Eth.” You should see Eth in your Metamask account soon after!</p><h4>Check your Balance</h4><p>To double check our balance is there, let’s make an <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_getbalance">eth_getBalance</a> request using <a href="https://composer.alchemyapi.io/?composer_state=%7B%22network%22%3A0%2C%22methodName%22%3A%22eth_getBalance%22%2C%22paramValues%22%3A%5B%22%22%2C%22latest%22%5D%7D">Alchemy’s composer tool</a>. This will return the amount of Eth in our wallet. After you input your Metamask account address and click “Send Request”, you should see a response like this:</p><pre>{“jsonrpc”: “2.0”, “id”: 0, “result”: “0xde0b6b3a7640000”}</pre><p><strong>ℹ️ NOTE: </strong>This result is in wei not eth. Wei is used as the smallest denomination of ether. The conversion from wei to eth is: 1 eth = 1⁰¹⁸ wei. So if we convert 0xde0b6b3a7640000 to decimal we get 1*10¹⁸ which equals 1 eth.</p><p>Phew! Our fake money is all there! 🤑</p><h3>Step 5: Connect Metamask to your UI</h3><p>Now that our Metamask wallet is set up, let’s connect our dApp to it!</p><h4>The connectWallet function</h4><p>In our interact.jsfile, let&#39;s implement the connectWallet function, which we can then call in our HelloWorld.js component.</p><p>Let’s modify connectWallet to the following:</p><pre>/* interact.js */</pre><pre>export const connectWallet = async () =&gt; {<br>  if (window.ethereum) {<br>    try {<br>      const addressArray = await window.ethereum.request({<br>        method: &quot;eth_requestAccounts&quot;,<br>      });<br>      const obj = {<br>        status: &quot;👆🏽 Write a message in the text-field above.&quot;,<br>        address: addressArray[0],<br>      };<br>      return obj;<br>    } catch (err) {<br>      return {<br>        address: &quot;&quot;,<br>        status: &quot;😥 &quot; + err.message,<br>      };<br>    }<br>  } else {<br>    return {<br>      address: &quot;&quot;,<br>      status: (<br>        &lt;span&gt;<br>          &lt;p&gt;<br>            {&quot; &quot;}<br>            🦊{&quot; &quot;}<br>            &lt;a target=&quot;_blank&quot; href={`<a href="https://metamask.io/download.html%60">https://metamask.io/download.html`</a>}&gt;<br>              You must install Metamask, a virtual Ethereum wallet, in your<br>              browser.<br>            &lt;/a&gt;<br>          &lt;/p&gt;<br>        &lt;/span&gt;<br>      ),<br>    };<br>  }<br>};</pre><p>So what does this giant block of code do exactly?</p><p>Well, first, it checks if it window.ethereum is enabled in your browser.</p><p><strong>ℹ️ NOTE: </strong>window.ethereum is a global API injected by Metamask and other wallet providers that allows websites to request users&#39; Ethereum accounts. If approved, it can read data from the blockchains the user is connected to, and suggest that the user sign messages and transactions . Check out the <a href="https://docs.metamask.io/guide/ethereum-provider.html#table-of-contents">Metamask docs</a> for more info!</p><p>If window.ethereum <em>is not</em> present, then that means Metamask is not installed. This results in a JSON object being returned, where address returned is an empty string, and the status JSX object relays that the user must install Metamask.</p><p>Now if window.ethereum <em>is</em> present, then that&#39;s when things get interesting.</p><p>Using a try/catch loop, we’ll try to connect to Metamask by calling<a href="https://docs.metamask.io/guide/rpc-api.html#eth-requestaccounts">window.ethereum.request({ method: &quot;eth_requestAccounts&quot; });</a> Calling this function will open up Metamask in the browser, whereby the user will be prompted to connect their wallet to your dApp.</p><ul><li>If the user chooses to connect, method: &quot;eth_requestAccounts&quot; will return an array that contains all of the user&#39;s account addresses that connected to the dApp. Altogether, our connectWallet function will return a JSON object that contains the <em>first</em> address in this array (see line 9) and a status message that prompts the user to write a message to the smart contract.</li><li>If the user rejects the connection, then the JSON object will contain an empty string for the address returned and a status message that reflects that the user rejected the connection.</li></ul><p>Now that we’ve written this connectWallet function, the next step is to call it to our HelloWorld.jscomponent.</p><h4>Add the connectWallet function to your HelloWorld.js UI Component</h4><p>Navigate to the connectWalletPressed function in HelloWorld.js, and update it to the following:</p><pre>/* HelloWorld.js */</pre><pre>  const connectWalletPressed = async () =&gt; {<br>    const walletResponse = await connectWallet();<br>    setStatus(walletResponse.status);<br>    setWallet(walletResponse.address);<br>  };</pre><p>Notice how most of our functionality is abstracted away from our HelloWorld.js component from the interact.js file? This is so we comply with the M-V-C paradigm!</p><p>In connectWalletPressed, we simply make an await call to our imported connectWallet function, and using its response, we update our status and walletAddress variables via their state hooks.</p><p>Now, let’s save both files (HelloWorld.js and interact.js) and test out our UI so far.</p><p>Open your browser on the <a href="http://localhost:3000/">http://localhost:3000/</a> page, and press the “Connect Wallet” button on the top right of the page.</p><p>If you have Metamask installed, you should be prompted to connect your wallet to your dApp. Accept the invitation to connect.</p><p>You should see that the wallet button now reflects that your address is connected! Yasssss 🔥</p><p>Next, try refreshing the page… this is strange. Our wallet button is prompting us to connect Metamask, even though it is already connected…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*oIXq1x8hJZ1aV8bq" /><figcaption>The problem on page reload</figcaption></figure><p>However, have no fear! We easily can address that (get it? 😅) by implementing getCurrentWalletConnected, which will check if an address is already connected to our dApp and update our UI accordingly!</p><h4>The getCurrentWalletConnected function</h4><p>Update your getCurrentWalletConnected function in the interact.js file to the following:</p><pre>/* interact.js */</pre><pre>export const getCurrentWalletConnected = async () =&gt; {<br>  if (window.ethereum) {<br>    try {<br>      const addressArray = await window.ethereum.request({<br>        method: &quot;eth_accounts&quot;,<br>      });<br>      if (addressArray.length &gt; 0) {<br>        return {<br>          address: addressArray[0],<br>          status: &quot;👆🏽 Write a message in the text-field above.&quot;,<br>        };<br>      } else {<br>        return {<br>          address: &quot;&quot;,<br>          status: &quot;🦊 Connect to Metamask using the top right button.&quot;,<br>        };<br>      }<br>    } catch (err) {<br>      return {<br>        address: &quot;&quot;,<br>        status: &quot;😥 &quot; + err.message,<br>      };<br>    }<br>  } else {<br>    return {<br>      address: &quot;&quot;,<br>      status: (<br>        &lt;span&gt;<br>          &lt;p&gt;<br>            {&quot; &quot;}<br>            🦊{&quot; &quot;}<br>            &lt;a target=&quot;_blank&quot; href={`<a href="https://metamask.io/download.html%60">https://metamask.io/download.html`</a>}&gt;<br>              You must install Metamask, a virtual Ethereum wallet, in your<br>              browser.<br>            &lt;/a&gt;<br>          &lt;/p&gt;<br>        &lt;/span&gt;<br>      ),<br>    };<br>  }<br>};</pre><p>This code is <em>very</em> similar to the connectWallet function we just wrote in the previous step.</p><p>The main difference is that instead of calling the method eth_requestAccounts, which opens Metamask for the user to connect their wallet, here we call the method eth_accounts, which simply returns an array containing the Metamask addresses currently connected to our dApp.</p><p>To see this function in action, let’s call it in our useEffect function of our HelloWorld.js component:</p><pre>/* HelloWorld.js */</pre><pre>useEffect(async () =&gt; {<br>    const message = await loadCurrentMessage();<br>    setMessage(message);<br>    addSmartContractListener();<br>    <br>    const {address, status} = await getCurrentWalletConnected();<br>    setWallet(address)<br>    setStatus(status);</pre><pre>}, []);</pre><p>Notice, we use the response of our call to getCurrentWalletConnected to update our walletAddress and status state variables.</p><p>Now that you’ve added this code, let’s try refreshing our browser window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*3llBlEYFYx2pIv4s" /><figcaption>It’s working!!!!!</figcaption></figure><p>Niceeeee! The button should say that you’re connected, and show a preview of your connected wallet’s address — even after you refresh!</p><h4>Implement addWalletListener</h4><p>The final step in our dApp wallet setup is implementing the wallet listener so our UI updates when our wallet’s state changes, such as when the user disconnects or switches accounts.</p><p>In your HelloWorld.js file, modify your addWalletListener function as the following:</p><pre>/* HelloWorld.js */</pre><pre>function addWalletListener() {<br>  if (window.ethereum) {<br>    window.ethereum.on(&quot;accountsChanged&quot;, (accounts) =&gt; {<br>      if (accounts.length &gt; 0) {<br>        setWallet(accounts[0]);<br>        setStatus(&quot;👆🏽 Write a message in the text-field above.&quot;);<br>      } else {<br>        setWallet(&quot;&quot;);<br>        setStatus(&quot;🦊 Connect to Metamask using the top right button.&quot;);<br>      }<br>    });<br>  } else {<br>    setStatus(<br>      &lt;p&gt;<br>        {&quot; &quot;}<br>        🦊{&quot; &quot;}<br>        &lt;a target=&quot;_blank&quot; href={`<a href="https://metamask.io/download.html%60">https://metamask.io/download.html`</a>}&gt;<br>          You must install Metamask, a virtual Ethereum wallet, in your<br>          browser.<br>        &lt;/a&gt;<br>      &lt;/p&gt;<br>    );<br>  }<br>}</pre><p>I bet you don’t even need our help to understand what’s going on here at this point 😉, but for thoroughness purposes, let’s quickly break it down:</p><p>First, our function checks if window.ethereum is enabled (i.e. Metamask is installed).</p><ul><li>If it’s not, we simply set our status state variable to a JSX string that prompts the user to install Metamask.</li><li>If it is enabled, we set up the listener window.ethereum.on(&quot;accountsChanged&quot;) on line 3 that listens for state changes in the Metamask wallet, which include when the user connects an additional account to the dApp, switches accounts, or disconnects an account. If there is at least one account connected, the walletAddress state variable is updated as the first account in the accounts array returned by the listener. Otherwise, walletAddress is set as an empty string.</li></ul><p>Last but not least, we must call it in our useEffect function:</p><pre>/* HelloWorld.js */</pre><pre>useEffect(async () =&gt; {<br>    const message = await loadCurrentMessage();<br>    setMessage(message);<br>    addSmartContractListener();<br>    <br>    const {address, status} = await getCurrentWalletConnected();<br>    setWallet(address)<br>    setStatus(status); <br>    <br>    addWalletListener(); <br>}, []);</pre><p>And that’s it! We’ve successfully completed programming all of our wallet functionality! Now onto our last task: updating the message stored in our smart contract!</p><h3>Step 6: Implement the updateMessage function</h3><p>🏃🏽‍♀️Alrighty fam, we’ve arrived at the home stretch! In the updateMessage of your interact.js file, we&#39;re going to do the following:</p><ol><li>Make sure the message we wish to publish in our smart contact is valid</li><li>Sign our transaction using Metamask</li><li>Call this function from our HelloWorld.js frontend component</li></ol><p>This won’t take very long; let’s finish this dApp!</p><h4>Input error handling</h4><p>Naturally, it makes sense to have some sort of input error handling at the start of the function.</p><p>We’ll want to our function to return early if there is no Metamask extension installed, there is no wallet connected (i.e. the address passed in is an empty string), or the message is an empty string. Let&#39;s add the following error handling to updateMessage:</p><pre>/* interact.js */</pre><pre>export const updateMessage = async (address, message) =&gt; {<br>  if (!window.ethereum || address === null) {<br>    return {<br>      status:<br>        &quot;💡 Connect your Metamask wallet to update the message on the blockchain.&quot;,<br>    };<br>  }</pre><pre>if (message.trim() === &quot;&quot;) {<br>    return {<br>      status: &quot;❌ Your message cannot be an empty string.&quot;,<br>    };<br>  }<br>};</pre><p>Now that it have proper input error handling, it’s time to sign the transaction via Metamask!</p><h4>Signing our transaction</h4><p>If you’re already comfortable with traditional web3 Ethereum transactions, the code we write next will be very familiar. Below your input error handling code, add the following to updateMessage:</p><pre>/* interact.js */</pre><pre>//set up transaction parameters<br> const transactionParameters = {<br>    to: contractAddress, // Required except during contract publications.<br>    from: address, // must match user&#39;s active address.<br>    data: helloWorldContract.methods.update(message).encodeABI(),<br>  };</pre><pre>//sign the transaction<br>  try {<br>    const txHash = await window.ethereum.request({<br>      method: &quot;eth_sendTransaction&quot;,<br>      params: [transactionParameters],<br>    });<br>    return {<br>      status: (<br>        &lt;span&gt;<br>          ✅{&quot; &quot;}<br>          &lt;a target=&quot;_blank&quot; href={`<a href="https://ropsten.etherscan.io/tx/$%7BtxHash%7D%60">https://ropsten.etherscan.io/tx/${txHash}`</a>}&gt;<br>            View the status of your transaction on Etherscan!<br>          &lt;/a&gt;<br>          &lt;br /&gt;<br>          ℹ️ Once the transaction is verified by the network, the message will<br>          be updated automatically.<br>        &lt;/span&gt;<br>      ),<br>    };<br>  } catch (error) {<br>    return {<br>      status: &quot;😥 &quot; + error.message,<br>    };<br>  }</pre><p>Let’s breakdown what’s happening. First, we set up our transactions parameters, where:</p><ul><li>to specifies the the recipient address (our smart contract)</li><li>from specifies the signer of the transaction, the address variable we passed into our function</li><li>data contains the call to our Hello World smart contract&#39;s update method, receiving our message string variable as input</li></ul><p>Then, we make an await call, window.ethereum.request, where we ask Metamask to sign the transaction. Notice, on lines 11 and 12, we&#39;re specifying our eth method, eth_sendTransactionand passing in our transactionParameters.</p><p>At this point, Metamask will open up in the browser, and prompt the user to sign or reject the transaction.</p><ul><li>If the transaction is successful, the function will return a JSON object where the status JSX string prompts the user to check out Etherscan for more information about their transaction.</li><li>If the transaction fails, the function will return a JSON object where the status string relays the error message.</li></ul><p>Altogether, our updateMessage function should look like this:</p><pre>/* interact.js */</pre><pre>export const updateMessage = async (address, message) =&gt; {<br>  <br>  //input error handling<br>  if (!window.ethereum || address === null) {<br>    return {<br>      status:<br>        &quot;💡 Connect your Metamask wallet to update the message on the blockchain.&quot;,<br>    };<br>  }</pre><pre>if (message.trim() === &quot;&quot;) {<br>    return {<br>      status: &quot;❌ Your message cannot be an empty string.&quot;,<br>    };<br>  }<br>  <br>  //set up transaction parameters<br>  const transactionParameters = {<br>    to: contractAddress, // Required except during contract publications.<br>    from: address, // must match user&#39;s active address.<br>    data: helloWorldContract.methods.update(message).encodeABI(),<br>  };</pre><pre>//sign the transaction<br>  try {<br>    const txHash = await window.ethereum.request({<br>      method: &quot;eth_sendTransaction&quot;,<br>      params: [transactionParameters],<br>    });<br>    return {<br>      status: (<br>        &lt;span&gt;<br>          ✅{&quot; &quot;}<br>          &lt;a target=&quot;_blank&quot; href={`<a href="https://ropsten.etherscan.io/tx/$%7BtxHash%7D%60">https://ropsten.etherscan.io/tx/${txHash}`</a>}&gt;<br>            View the status of your transaction on Etherscan!<br>          &lt;/a&gt;<br>          &lt;br /&gt;<br>          ℹ️ Once the transaction is verified by the network, the message will<br>          be updated automatically.<br>        &lt;/span&gt;<br>      ),<br>    };<br>  } catch (error) {<br>    return {<br>      status: &quot;😥 &quot; + error.message,<br>    };<br>  }<br>};</pre><p>Last but not least, we need to connect our updateMessage function to our HelloWorld.js component.</p><h4>Connect updateMessage to the HelloWorld.js frontend</h4><p>Our onUpdatePressed function should make an await call to the imported updateMessage function and modify the status state variable to reflect whether our transaction succeeded or failed:</p><pre>/* HelloWorld.js */</pre><pre>const onUpdatePressed = async () =&gt; {<br>    const { status } = await updateMessage(walletAddress, newMessage);<br>    setStatus(status);<br>};</pre><p>It’s super clean and simple. 😌And guess what…YOUR DAPP IS COMPLETE!!!</p><p>Let’s test out the “Update” button!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*F2JJclALGusNCMXc" /><figcaption>DApp “Update” button demo</figcaption></figure><h3>Step 7: Make your own custom dApp 🚀</h3><p>Wooooo, you made it to the end of the tutorial! To recap, you learned how to:</p><ul><li>Connect a Metamask wallet to your dApp project</li><li>Read data from your smart contract using the <a href="https://docs.alchemy.com/alchemy/documentation/alchemy-web3">Alchemy Web3</a> API</li><li>Sign Ethereum transactions using Metamask</li></ul><p>Now you’re fully equipped to apply the skills from this tutorial to build out your own custom dApp project! As always, if you have any questions, don’t hesitate to reach out to us for help in the <a href="https://discord.gg/gWuC7zB">Alchemy Discord</a>. 🧙‍♂️</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:52c81d50-8654-4ea4-b8fc-ba8f8d575950"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide and the biggest players in the NFT space, including OpenSea, Nifty Gateway, Makersplace, Dapper Labs, Zora, NFTfi, Super Rare, Foundation, Enjin, Origin Protocol, Immutable, and more. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $30 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e0302e449af" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/integrating-your-smart-contract-with-the-frontend-4e0302e449af">📱Integrating Your Smart Contract with the Frontend</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ NFT Minter Tutorial: How to Create a Full Stack DApp]]></title>
            <link>https://medium.com/alchemy-api/nft-minter-tutorial-how-to-create-a-full-stack-dapp-3c5966c3c0d6?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c5966c3c0d6</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[metamask]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Fri, 23 Apr 2021 17:43:39 GMT</pubDate>
            <atom:updated>2021-05-24T06:34:01.713Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this tutorial, you’ll build an NFT minter and learn how to create a full stack dApp by connecting your smart contract to a React frontend using Metamask and Web3 tools.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x8q7C0botxO4nfcVOjGlkw.png" /></figure><p>One of the greatest challenges for developers coming from a Web2 background is figuring out how to connect your smart contact to a frontend project and interact with it.</p><p>By building an NFT minter — a simple UI where you can input a link to your digital asset, a title, and a description — you’ll learn how to:</p><ul><li>Connect to Metamask via your frontend project</li><li>Call smart contract methods from your frontend</li><li>Sign transactions using Metamask</li></ul><p>In this tutorial, we will be using <a href="https://reactjs.org/">React</a> as our frontend framework. Because this tutorial is primarily focused on Web3 development, we won’t be spending much time breaking down React fundamentals. Instead, we’ll be focusing on bringing functionality to our project.</p><p>ℹ️ <strong>INFO:</strong> As a prerequisite, you should have a beginner-level understanding of React — know how components, props, useState/useEffect, and basic function calling works. If you’ve never heard of any of those terms before, you may want to check out this <a href="https://reactjs.org/tutorial/tutorial.html">Intro to React tutorial</a>. For the more visual learners, we highly recommend this excellent <a href="https://www.youtube.com/playlist?list=PL4cUxeGkcC9gZD-Tvwfod2gaISzfRiP9d">Full Modern React Tutorial</a> video series by Net Ninja.</p><p>Without further ado, let’s get started!</p><h3>Step 0: Making NFTs 101</h3><p>Before we even start looking at any code, it’s important to understand how making an NFT works. It involves two steps:</p><p>1) You publish an NFT smart contract on the Ethereum blockchain. Usually this is an <a href="https://eips.ethereum.org/EIPS/eip-721">ERC-721</a> or <a href="https://eips.ethereum.org/EIPS/eip-1155">ERC-1155</a> smart contract.</p><p>ℹ️ <strong>INFO: </strong>The biggest difference between the two NFT smart contact standards is that ERC-1155 is a multi-token standard and includes batch functionality, whereas with the ERC-721 is a single-token standard and therefore only supports transferring one token at a time.</p><p>2) You call the minting function on that NFT smart contract to mint the NFT. <em>Minting</em> is simply the act of publishing a unique instance of your non fungible token on the blockchain.</p><p>Usually, this minting function requires you to pass in two variables as parameters, first the recipient, which specifies the address that will receive your freshly minted NFT, and second the NFT&#39;s tokenURI , a string that resolves to a JSON document describing the NFT&#39;s metadata.</p><p>ℹ️ <strong>INFO:</strong> An NFT’s metadata is really what brings it to life, allowing it to have properties, such as a name, description, image (or different digital asset), and other attributes. Here’s <a href="https://gateway.pinata.cloud/ipfs/QmSvBcb4tjdFpajGJhbFAWeK3JAxCdNQLQtr6ZdiSi42V2">an example of a tokenURI</a>, which contains an NFT’s metadata.</p><p>In this tutorial, we’re going to focus on part 2, calling an existing NFT’s smart contract minting function using our React UI.</p><p><a href="https://ropsten.etherscan.io/address/0x4C4a07F737Bf57F6632B6CAB089B78f62385aCaE">Here’s a link</a> to the ERC-721 NFT smart contract we will be calling in this tutorial. If you’d like to learn how we made it, we highly recommend that you check out our other tutorial, <a href="https://medium.com/alchemy/tutorials/how-to-create-an-nft">🎨 How to Create an NFT</a>.</p><p>Cool, now that we understand how making an NFT works, let’s clone our starter files!</p><h3>Step 1: Clone the starter files</h3><p>First, go to the <a href="https://github.com/alchemyplatform/nft-minter-tutorial">nft-minter-tutorial</a> github repository to get the starter files for this project. Clone this repository into your local environment.</p><p>ℹ️ <strong>INFO: </strong>Don’t know how to clone a repository? Check out <a href="https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository">this guide</a> from Github.</p><p>When you open this cloned nft-minter-tutorial repository, you&#39;ll notice that it contains two folders: minter-starter-files and nft-minter.</p><ul><li>minter-starter-filescontains the starter files (essentially the React UI) for this project. In this tutorial, <strong>we will be working in this directory</strong>, as you learn how to bring this UI to life by connecting it to your Ethereum wallet and an NFT smart contract.</li><li>nft-minter contains the entire completed tutorial and is there for you as a <strong>reference</strong> <strong>if you get stuck.</strong></li></ul><p>Next open your copy of minter-starter-filesin to your favorite code editor (at Alchemy, we we&#39;re big fans of <a href="https://code.visualstudio.com/download">VSCode</a>), and then navigate into your src folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EUHgrr1Uft4dcGiI.png" /><figcaption>We will work inside the “src” folder</figcaption></figure><p>All of the code we’ll write will live under the src folder. We&#39;ll be editing the Minter.js component and writing additional javascript files to give our project Web3 functionality.</p><h3>Step 2: Check out our starter files</h3><p>Before we start coding, it’s important check out what’s already provided for us in the starter files.</p><h4>Get your react project running</h4><p>Let’s start by running the React project in our browser. The beauty of React is that once we have our project running in our browser, any changes we save will be updated live in our browser.</p><p>To get the project running, navigate to the root directory of the minter-starter-files folder, and the run npm install in your terminal to install the dependencies of the project:</p><pre>cd minter-starter-files<br>npm install</pre><p>Once those have finished installing, run npm start in your terminal:</p><pre>npm start</pre><p>Doing so should open <a href="http://localhost:3000/">http://localhost:3000/</a> in your browser, where you’ll see the frontend for our project. It should consist of 3 fields: a place to input a link to your NFT’s asset, enter the name of your NFT, and provide a description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zRmXp8QmNqIh89SL.png" /><figcaption>What your UI should look like</figcaption></figure><p>If you try clicking “Connect Wallet” or “Mint NFT” buttons, you’ll notice they don’t work — that’s because we still need to program their functionality! :)</p><h4>The Minter.js component</h4><p><strong>⚠️ NOTE: </strong>Make sure you’re in the minter-starter-files folder and not the nft-minterfolder!</p><p>Let’s go back into the src folder in our editor and open the Minter.js file. It&#39;s super important that we understand everything in this file, as it is the primary React component we will be working on.</p><p>At the top of our this file, we have our state variables that we will update after specific events.</p><pre>//State variables<br>const [walletAddress, setWallet] = useState(&quot;&quot;);<br>const [status, setStatus] = useState(&quot;&quot;);<br>const [name, setName] = useState(&quot;&quot;);<br>const [description, setDescription] = useState(&quot;&quot;);<br>const [url, setURL] = useState(&quot;&quot;);</pre><p>ℹ️ <strong>INFO: </strong>Never heard of React state variables or state hooks? Check out <a href="https://reactjs.org/docs/hooks-state.html">these</a> docs.</p><p>Here’s what each of the variables represent:</p><ul><li>walletAddress - a string that stores the user&#39;s wallet address</li><li>status- a string that contains a message to display at the bottom of the UI</li><li>name - a string that stores the NFT&#39;s name</li><li>description - a string that stores the NFT&#39;s description</li><li>url - a string that is a link to the NFT&#39;s digital asset</li></ul><p>After the state variables, you’ll see three un-implemented functions: useEffect, connectWalletPressed, and onMintPressed. You&#39;ll notice that all of these functions are async, that&#39;s because we will be making asynchronous API calls in them! Their names are eponymous with their functionalities:</p><pre>useEffect(async () =&gt; { //TODO: implement</pre><pre>}, []);</pre><pre>const connectWalletPressed = async () =&gt; { //TODO: implement</pre><pre>};</pre><pre>const onMintPressed = async () =&gt; { //TODO: implement</pre><pre>};</pre><ul><li><a href="https://reactjs.org/docs/hooks-effect.html">useEffect</a>- this is a React hook that is called after your component is rendered. Because it has an empty array [] prop passed into it (see line 3), it will only be called on the component&#39;s <em>first</em> render. Here we&#39;ll call our wallet listener and another wallet function to update our UI to reflect whether a wallet is already connected.</li><li>connectWalletPressed- this function will be called to connect the user&#39;s Metamask wallet to our dApp.</li><li>onMintPressed - this function will be called to mint the user&#39;s NFT.</li></ul><p>Near the end of this file, we have the UI of our component. If you scan this code carefully, you’ll notice that we update our url, name, and description state variables when the input in their corresponding text fields change.</p><p>You’ll also see that connectWalletPressed and onMintPressedare called when the buttons with IDs mintButton and walletButton are clicked respectively.</p><pre>//the UI of our component</pre><pre>  return (<br>    &lt;div className=&quot;Minter&quot;&gt;<br>      &lt;button id=&quot;walletButton&quot; onClick={connectWalletPressed}&gt;<br>        {walletAddress.length &gt; 0 ? (<br>          &quot;Connected: &quot; +<br>          String(walletAddress).substring(0, 6) +<br>          &quot;...&quot; +<br>          String(walletAddress).substring(38)<br>        ) : (<br>          &lt;span&gt;Connect Wallet&lt;/span&gt;<br>        )}<br>      &lt;/button&gt;</pre><pre>&lt;br&gt;&lt;/br&gt;<br>      &lt;h1 id=&quot;title&quot;&gt;🧙‍♂️ Alchemy NFT Minter&lt;/h1&gt;<br>      &lt;p&gt;<br>        Simply add your asset&#39;s link, name, and description, then press &quot;Mint.&quot;<br>      &lt;/p&gt;<br>      &lt;form&gt;<br>        &lt;h2&gt;🖼 Link to asset: &lt;/h2&gt;<br>        &lt;input<br>          type=&quot;text&quot;<br>          placeholder=&quot;e.g. <a href="https://gateway.pinata.cloud/ipfs/">https://gateway.pinata.cloud/ipfs/</a>&lt;hash&gt;&quot;<br>          onChange={(event) =&gt; setURL(event.target.value)}<br>        /&gt;<br>        &lt;h2&gt;🤔 Name: &lt;/h2&gt;<br>        &lt;input<br>          type=&quot;text&quot;<br>          placeholder=&quot;e.g. My first NFT!&quot;<br>          onChange={(event) =&gt; setName(event.target.value)}<br>        /&gt;<br>        &lt;h2&gt;✍️ Description: &lt;/h2&gt;<br>        &lt;input<br>          type=&quot;text&quot;<br>          placeholder=&quot;e.g. Even cooler than cryptokitties ;)&quot;<br>          onChange={(event) =&gt; setDescription(event.target.value)}<br>        /&gt;<br>      &lt;/form&gt;<br>      &lt;button id=&quot;mintButton&quot; onClick={onMintPressed}&gt;<br>        Mint NFT<br>      &lt;/button&gt;<br>      &lt;p id=&quot;status&quot;&gt;<br>        {status}<br>      &lt;/p&gt;<br>    &lt;/div&gt;<br>  );</pre><p>Finally, let’s address where is this Minter component added.</p><p>If you go to the App.js file, which is the main component in React that acts as a container for all other components, you&#39;ll see that our Minter component is injected on line 7.</p><p><strong>In this tutorial, we’ll only be editing the </strong><strong>Minter.js file and adding files in our </strong><strong>src folder.</strong></p><p>Now that we understand what we’re working with, let’s set up our Ethereum wallet!</p><h3>Step 3: Set up your Ethereum wallet</h3><p>For users to be able to interact with your smart contract they will need to connect their Ethereum wallet to your dApp.</p><h4>Download Metamask</h4><p>For this tutorial, we’ll use Metamask, a virtual wallet in the browser used to manage your Ethereum account address. If you want to understand more about how transactions on Ethereum work, check out <a href="https://ethereum.org/en/developers/docs/transactions/">this page</a> from the Ethereum foundation.</p><p>You can download and create a Metamask account for free <a href="https://metamask.io/download.html">here</a>. When you are creating an account, or if you already have an account, make sure to switch over to the “Ropsten Test Network” in the upper right (so that we’re not dealing with real money).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/0*gKh3HkXVoMmrhjQz" /><figcaption>Sample Metamask wallet</figcaption></figure><h4>Add ether from a Faucet</h4><p>In order to mint our NFTs (or sign any transactions on the Ethereum blockchain), we’ll need some fake Eth. To get Eth you can go to the <a href="https://faucet.ropsten.be/">Ropsten faucet</a> and enter your Ropsten account address, then click “Send Ropsten Eth.” You should see Eth in your Metamask account soon after!</p><h4>Check your Balance</h4><p>To double check our balance is there, let’s make an <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_getbalance">eth_getBalance</a> request using <a href="https://composer.alchemyapi.io/?composer_state=%7B%22network%22%3A0%2C%22methodName%22%3A%22eth_getBalance%22%2C%22paramValues%22%3A%5B%22%22%2C%22latest%22%5D%7D">Alchemy’s composer tool</a>. This will return the amount of Eth in our wallet. After you input your Metamask account address and click “Send Request”, you should see a response like this:</p><pre>{&quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;id&quot;: 0, &quot;result&quot;: &quot;0xde0b6b3a7640000&quot;}</pre><p><strong>✅ NOTE: </strong>This result is in wei not eth. Wei is used as the smallest denomination of ether. The conversion from wei to eth is: 1 eth = 1⁰¹⁸ wei. So if we convert 0xde0b6b3a7640000 to decimal we get 1*1⁰¹⁸ which equals 1 eth.</p><p>Phew! Our fake money is all there! 🤑</p><h3>Step 4: Connect Metamask to your UI</h3><p>Now that our Metamask wallet is set up, let’s connect our dApp to it!‌</p><p>Because we want to prescribe to the <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">M-V-C</a> paradigm, we’re going to create a separate file that contains our functions to manage the logic, data, and rules of our dApp, and then pass those functions to our frontend (our Minter.js component).</p><h4>The connectWallet function</h4><p>To do so, let’s create a new folder called utilsin your src directory and add a file called interact.js inside it, which will contain all of our wallet and smart contract interaction functions.‌</p><p>In our interact.jsfile, we will write a connectWallet function, which we will then import and call in our Minter.js component.‌</p><p>In your interact.js file, add the following</p><pre>export const connectWallet = async () =&gt; {<br>  if (window.ethereum) {<br>    try {<br>      const addressArray = await window.ethereum.request({<br>        method: &quot;eth_requestAccounts&quot;,<br>      });<br>      const obj = {<br>        status: &quot;👆🏽 Write a message in the text-field above.&quot;,<br>        address: addressArray[0],<br>      };<br>      return obj;<br>    } catch (err) {<br>      return {<br>        address: &quot;&quot;,<br>        status: &quot;😥 &quot; + err.message,<br>      };<br>    }<br>  } else {<br>    return {<br>      address: &quot;&quot;,<br>      status: (<br>        &lt;span&gt;<br>          &lt;p&gt;<br>            {&quot; &quot;}<br>            🦊{&quot; &quot;}<br>            &lt;a target=&quot;_blank&quot; href={`<a href="https://metamask.io/download.html%60">https://metamask.io/download.html`</a>}&gt;<br>              You must install Metamask, a virtual Ethereum wallet, in your<br>              browser.<br>            &lt;/a&gt;<br>          &lt;/p&gt;<br>        &lt;/span&gt;<br>      ),<br>    };<br>  }<br>};</pre><p>Let’s breakdown what this code does:</p><p>First, our function checks if it window.ethereum is enabled in your browser.</p><p>ℹ️ <strong>INFO: </strong>window.ethereum is a global API injected by Metamask and other wallet providers that allows websites to request users&#39; Ethereum accounts. If approved, it can read data from the blockchains the user is connected to, and suggest that the user sign messages and transactions . Check out the <a href="https://docs.metamask.io/guide/ethereum-provider.html#table-of-contents">Metamask docs</a> for more info!</p><p>If window.ethereum <em>is not</em> present, then that means Metamask is not installed. This results in a JSON object being returned, where address returned is an empty string, and the status JSX object relays that the user must install Metamask.</p><p><strong>✅ NOTE: Most of the functions we write will be returning JSON objects that we can use to update our state variables and UI.</strong></p><p>Now if window.ethereum <em>is</em> present, then that&#39;s when things get interesting.‌</p><p>Using a try/catch loop, we’ll try to connect to Metamask by calling<a href="https://docs.metamask.io/guide/rpc-api.html#eth-requestaccounts">window.ethereum.request({ method: &quot;eth_requestAccounts&quot; });</a> Calling this function will open up Metamask in the browser, whereby the user will be prompted to connect their wallet to your dApp.‌</p><ul><li>If the user chooses to connect, method: &quot;eth_requestAccounts&quot; will return an array that contains all of the user&#39;s account addresses that connected to the dApp. Altogether, our connectWallet function will return a JSON object that contains the <em>first</em> address in this array (see line 9) and a status message that prompts the user to write a message to the smart contract.</li><li>If the user rejects the connection, then the JSON object will contain an empty string for the address returned and a status message that reflects that the user rejected the connection.</li></ul><h4>Add connectWallet function to your Minter.js UI Component</h4><p>Now that we’ve written this connectWallet function, let&#39;s connect it to our Minter.js. component.‌</p><p>First, we’ll have to import our function into our Minter.js file by adding import { connectWallet } from &quot;./utils/interact.js&quot;; to the top of the Minter.js file. Your first 11 lines of Minter.js should now look like this:</p><pre>import { useEffect, useState } from &quot;react&quot;;<br>import { connectWallet } from &quot;./utils/interact.js&quot;;</pre><pre>const Minter = (props) =&gt; {</pre><pre>//State variables<br>  const [walletAddress, setWallet] = useState(&quot;&quot;);<br>  const [status, setStatus] = useState(&quot;&quot;);<br>  const [name, setName] = useState(&quot;&quot;);<br>  const [description, setDescription] = useState(&quot;&quot;);<br>  const [url, setURL] = useState(&quot;&quot;);</pre><p>Then, inside our connectWalletPressed function, we&#39;ll call our imported connectWallet function, like so:</p><pre>const connectWalletPressed = async () =&gt; {<br>    const walletResponse = await connectWallet();<br>    setStatus(walletResponse.status);<br>    setWallet(walletResponse.address);<br>  };</pre><p>Notice how most of our functionality is abstracted away from our Minter.js component from the interact.js file? This is so we comply with the M-V-C paradigm!‌</p><p>In connectWalletPressed, we simply make an await call to our imported connectWallet function, and using its response, we update our status and walletAddress variables via their state hooks.‌</p><p>Now, let’s save both files (Minter.js and interact.js) and test out our UI so far.‌</p><p>Open your browser on the <a href="http://localhost:3000/">http://localhost:3000/</a> page, and press the “Connect Wallet” button on the top right of the page.‌</p><p>If you have Metamask installed, you should be prompted to connect your wallet to your dApp. Accept the invitation to connect.‌</p><p>You should see that the wallet button now reflects that your address is connected! Yasssss 🔥‌</p><p>Next, try refreshing the page… this is strange. Our wallet button is prompting us to connect Metamask, even though it is already connected…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*hDdBECrtydSQmuBddoOCHA.gif" /><figcaption>The problem on page reload</figcaption></figure><p>Don’t worry though! We easily can fix that by implementing a function calledgetCurrentWalletConnected, which will check if an address is already connected to our dApp and update our UI accordingly!</p><h4>The getCurrentWalletConnected function‌</h4><p>In your interact.js file, add the following getCurrentWalletConnected function:</p><pre>export const getCurrentWalletConnected = async () =&gt; {<br>  if (window.ethereum) {<br>    try {<br>      const addressArray = await window.ethereum.request({<br>        method: &quot;eth_accounts&quot;,<br>      });<br>      if (addressArray.length &gt; 0) {<br>        return {<br>          address: addressArray[0],<br>          status: &quot;👆🏽 Write a message in the text-field above.&quot;,<br>        };<br>      } else {<br>        return {<br>          address: &quot;&quot;,<br>          status: &quot;🦊 Connect to Metamask using the top right button.&quot;,<br>        };<br>      }<br>    } catch (err) {<br>      return {<br>        address: &quot;&quot;,<br>        status: &quot;😥 &quot; + err.message,<br>      };<br>    }<br>  } else {<br>    return {<br>      address: &quot;&quot;,<br>      status: (<br>        &lt;span&gt;<br>          &lt;p&gt;<br>            {&quot; &quot;}<br>            🦊{&quot; &quot;}<br>            &lt;a target=&quot;_blank&quot; href={`<a href="https://metamask.io/download.html%60">https://metamask.io/download.html`</a>}&gt;<br>              You must install Metamask, a virtual Ethereum wallet, in your<br>              browser.<br>            &lt;/a&gt;<br>          &lt;/p&gt;<br>        &lt;/span&gt;<br>      ),<br>    };<br>  }<br>};</pre><p>This code is <em>very</em> similar to the connectWallet function we just wrote earlier.‌</p><p>The main difference is that instead of calling the method eth_requestAccounts, which opens Metamask for the user to connect their wallet, here we call the method eth_accounts, which simply returns an array containing the Metamask addresses currently connected to our dApp.‌</p><p>To see this function in action, let’s call it in the useEffect function of our Minter.js component.‌</p><p>Like we did for connectWallet, we must import this function from our interact.js file into our Minter.js file like so:</p><pre>import { useEffect, useState } from &quot;react&quot;;<br>import {<br>  connectWallet,<br>  getCurrentWalletConnected //import here<br>} from &quot;./util/interact.js&quot;;</pre><p>Now, we simply call it in our useEffect function:</p><pre>useEffect(async () =&gt; {<br>    const {address, status} = await getCurrentWalletConnected();<br>    setWallet(address)<br>    setStatus(status); <br>}, []);</pre><p>Notice, we use the response of our call to getCurrentWalletConnected to update our walletAddress and status state variables.</p><p>‌Once you’ve added this code, try refreshing our browser window. The button should say that you’re connected, and show a preview of your connected wallet’s address — even after you refresh! 😅</p><h4>Implement addWalletListener</h4><p>‌The final step in our dApp wallet setup is implementing the wallet listener so our UI updates when our wallet’s state changes, such as when the user disconnects or switches accounts.‌</p><p>In your Minter.js file, add a function addWalletListener that looks like the following:</p><pre>function addWalletListener() {<br>  if (window.ethereum) {<br>    window.ethereum.on(&quot;accountsChanged&quot;, (accounts) =&gt; {<br>      if (accounts.length &gt; 0) {<br>        setWallet(accounts[0]);<br>        setStatus(&quot;👆🏽 Write a message in the text-field above.&quot;);<br>      } else {<br>        setWallet(&quot;&quot;);<br>        setStatus(&quot;🦊 Connect to Metamask using the top right button.&quot;);<br>      }<br>    });<br>  } else {<br>    setStatus(<br>      &lt;p&gt;<br>        {&quot; &quot;}<br>        🦊{&quot; &quot;}<br>        &lt;a target=&quot;_blank&quot; href={`<a href="https://metamask.io/download.html%60">https://metamask.io/download.html`</a>}&gt;<br>          You must install Metamask, a virtual Ethereum wallet, in your<br>          browser.<br>        &lt;/a&gt;<br>      &lt;/p&gt;<br>    );<br>  }<br>}</pre><p>Let’s quickly break down what’s happening here:‌</p><p>First, our function checks if window.ethereum is enabled (i.e. Metamask is installed).</p><ul><li>If it’s not, we simply set our status state variable to a JSX string that prompts the user to install Metamask.</li><li>If it is enabled, we set up the listener window.ethereum.on(&quot;accountsChanged&quot;) on line 3 that listens for state changes in the Metamask wallet, which include when the user connects an additional account to the dApp, switches accounts, or disconnects an account. If there is at least one account connected, the walletAddress state variable is updated as the first account in the accounts array returned by the listener. Otherwise, walletAddress is set as an empty string.‌</li></ul><p>Finally, we must call it in our useEffect function:</p><pre>useEffect(async () =&gt; {<br>    const {address, status} = await getCurrentWalletConnected();<br>    <br>    setWallet(address)<br>    setStatus(status);<br>    <br>    addWalletListener(); <br>}, []);</pre><p>And voila! We’ve completed programming all of our wallet functionality! Now that our wallet is set up, let’s figure out how to mint our NFT!</p><h3>Step 5: NFT Metadata 101</h3><p>So remember the NFT metadata we just talked about in Step 0 of this tutorial — it brings an NFT to life, allowing it to have properties, such as a digital asset, name, description, and other attributes.</p><p>We’re going to need to configure this metadata as a JSON object and store it, so we can pass it in as the tokenURI parameter when calling our smart contract&#39;s mintNFT function.</p><p>The text in the “Link to Asset”, “Name”, “Description” fields will comprise the different properties of our NFT’s metadata. We’ll format this metadata as a JSON object, but there are a couple options for where we can store this JSON object:</p><ul><li>We could store it on the Ethereum blockchain; however, doing so would be SUPER expensive (we’re talking upwards of hundreds of dollars) due to the nature of Ethereum. ❌</li><li>We could store it on a centralized server, like AWS or Firebase. But that would defeat our decentralization ethos. ❌</li><li>We could use IPFS, a decentralized protocol and peer-to-peer network for storing and sharing data in a distributed file system. As this protocol as decentralized and free, it is our best option! ✅</li></ul><p>To store our metadata on IPFS, we will use <a href="https://pinata.cloud/">Pinata</a>, a convenient IPFS API and toolkit. In the next step, we’ll explain exactly how to do this!</p><h3>Step 6: Use <a href="https://pinata.cloud/">Pinata</a> to pin your metadata to IPFS</h3><p>If you don’t have a Pinata account, sign up for a free account <a href="https://pinata.cloud/signup">here</a> and complete the steps to verify your email and account.</p><h4>Create your Pinata API key</h4><p>Navigate to the <a href="https://pinata.cloud/keys">https://pinata.cloud/keys</a> page, then select the “New Key” button at the top, set the Admin widget as enabled, and name your key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OADC9mWmcHB1VZtI.png" /><figcaption>Create your Pinata API key</figcaption></figure><p>You’ll then be shown a popup with your API info. Make sure to put this somewhere safe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5P2c44AzZHYO8t6y.png" /><figcaption>Make sure to save your API key and secret in a safe place</figcaption></figure><p>Now that our key is set up, let’s add it to our project so we can use it.</p><h4>Create a .env file</h4><p>We can safely store our Pinata key and secret in an environment file. Let’s install the <a href="https://www.npmjs.com/package/dotenv">dotenv package</a> in your project directory.</p><p>Open up a new tab in your terminal (separate from the one running local host) and make sure you are in the minter-starter-file.js folder, then run the following command in your terminal:</p><pre>npm install dotenv --save</pre><p>Next, create a .env file in the root directory of your minter-starter-files by entering the following on your command line:</p><pre>vim .env</pre><p>This will pop open your .env file in vim (a text editor). To save it hit &quot;esc&quot; + &quot;:&quot; + &quot;q&quot; on your keyboard in that order.</p><p>Next, in VSCode, navigate to your .env file and add your Pinata API key and API secret to it, like so:</p><pre>REACT_APP_PINATA_KEY = &lt;pinata-api-key&gt;<br>REACT_APP_PINATA_SECRET = &lt;pinata-api-secret&gt;</pre><p>Save the file, and then you’re ready to start writing the function to upload your JSON metadata to IPFS!</p><h4>Implement pinJSONToIPFS</h4><p>Fortunately for us, Pinata has an <a href="https://pinata.cloud/documentation#PinJSONToIPFS">API specifically for uploading JSON data to IPFS</a> and a convenient JavaScript with axios example that we can use, with some slight modifications.</p><p>In your utils folder, let&#39;s create another file called pinata.js and then import our Pinata secret and key from the .env file like so:</p><pre>require(&#39;dotenv&#39;).config();<br>const key = process.env.REACT_APP_PINATA_KEY;<br>const secret = process.env.REACT_APP_PINATA_SECRET;</pre><p>Next, paste the additional code from below into your pinata.js file. Don&#39;t worry, we&#39;ll break down what everything means!</p><pre>require(&#39;dotenv&#39;).config();<br>const key = process.env.REACT_APP_PINATA_KEY;<br>const secret = process.env.REACT_APP_PINATA_SECRET;</pre><pre>const axios = require(&#39;axios&#39;);</pre><pre>export const pinJSONToIPFS = async(JSONBody) =&gt; {<br>    const url = `<a href="https://api.pinata.cloud/pinning/pinJSONToIPFS%60">https://api.pinata.cloud/pinning/pinJSONToIPFS`</a>;<br>    //making axios POST request to Pinata ⬇️<br>    return axios <br>        .post(url, JSONBody, {<br>            headers: {<br>                pinata_api_key: key,<br>                pinata_secret_api_key: secret,<br>            }<br>        })<br>        .then(function (response) {<br>           return {<br>               success: true,<br>               pinataUrl: &quot;<a href="https://gateway.pinata.cloud/ipfs/">https://gateway.pinata.cloud/ipfs/</a>&quot; + response.data.IpfsHash<br>           };<br>        })<br>        .catch(function (error) {<br>            console.log(error)<br>            return {<br>                success: false,<br>                message: error.message,<br>            }<br>           <br>    });<br>};</pre><p>So what does this code do exactly?</p><p>First, it imports <a href="https://www.npmjs.com/package/axios">axios</a>, a promise based HTTP client for the browser and node.js, which we will use to make a request to Pinata.</p><p>Then we have our asynchronous function pinJSONToIPFS, which takes a JSONBody as its input and the Pinata api key and secret in its header, all to make a POST request to theirpinJSONToIPFS API.</p><ul><li>If this POST request is successful, then our function returns an JSON object with the success boolean as true and the pinataUrl where our metadata was pinned. We will use this pinataUrl returned as the tokenURI input to our smart contract&#39;s mint function.</li><li>If this post request fails, then our function returns an JSON object with the success boolean as false and a message string that relays our error.</li></ul><p>As with our connectWalletfunction return types, we&#39;re returning JSON objects so we can use their parameters to update our state variables and UI.</p><h3>Step 7: Load your smart contract</h3><p>Now that we have a way to upload our NFT metadata to IPFS via our pinJSONToIPFS function, we&#39;re going to need a way to load an instance of our smart contract so we can call its mintNFT function.</p><p>✅<strong> NOTE:</strong> As we mentioned earlier, in this tutorial we will be using <a href="https://ropsten.etherscan.io/address/0x4C4a07F737Bf57F6632B6CAB089B78f62385aCaE">this existing NFT smart contract</a>; however, if you’d like to learn how we made it, or make one yourself, we highly recommend you check out our other tutorial, <a href="https://docs.alchemyapi.io/alchemy/tutorials/how-to-create-an-nft">“How to Create an NFT.”</a></p><h4>The contract ABI</h4><p>If you examined our files closely, you’ll have noticed that in our src directory, there&#39;s a contract-abi.json file. An ABI is necessary for specifying which function a contract will invoke as well ensuring that the function will return data in the format you&#39;re expecting.</p><p>We’re also going to need an Alchemy API key and the Alchemy Web3 API to connect to the Ethereum blockchain and load our smart contract.</p><h4>Create your Alchemy API key</h4><p>If you don’t already have an Alchemy account, <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:8475f0fd-56af-4dbf-bcf2-9b379d1679e0">sign up for free here</a>.</p><p>Once you’ve created an Alchemy account, you can generate an API key by creating an app. This will allow us to make requests to the Ropsten test network.</p><p>Navigate to the “Create App” page in your Alchemy Dashboard by hovering over “Apps” in the nav bar and clicking “Create App”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3-ltl3HUXkxy7LkX.png" /><figcaption>Create a new app</figcaption></figure><p>Name your app (we chose “My First NFT!”), offer a short description, select “Staging” for the Environment (used for your app bookkeeping), and choose “Ropsten” for your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ae4v2TlHJeG-K_kH.png" /><figcaption>Configure your app details</figcaption></figure><p>Click “Create app” and that’s it! Your app should appear in the table below.</p><p>Awesome so now that we’ve created our HTTP Alchemy API URL, copy it to your clipboard like so…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/0*tVuqmBToOdn9Eys-.gif" /><figcaption>Copy your Alchemy API key</figcaption></figure><p>…and then let’s add it to our .env file. Altogether, your .env file should look like this:</p><pre>REACT_APP_PINATA_KEY = &lt;pinata-key&gt;<br>REACT_APP_PINATA_SECRET = &lt;pinata-secret&gt;<br>REACT_APP_ALCHEMY_KEY = https://eth-ropsten.alchemyapi.io/v2/&lt;alchemy-key&gt;</pre><p>Now that we have our contract ABI and our Alchemy API key, we’re ready to load our smart contract using<a href="https://github.com/alchemyplatform/alchemy-web3"> Alchemy Web3</a>.</p><h4>Set up your Alchemy Web3 endpoint and contract</h4><p>First, if you don’t have it already, you’ll need to install <a href="https://github.com/alchemyplatform/alchemy-web3">Alchemy Web3</a> by navigating to the home directory: nft-minter-tutorialin the terminal:</p><pre>cd ..<br>npm install @alch/alchemy-web3</pre><p>Next let’s go back to our interact.jsfile. At the top of the file, add the following code to import your Alchemy key from your .env file and set up your Alchemy Web3 endpoint:</p><pre>require(&#39;dotenv&#39;).config();<br>const alchemyKey = process.env.REACT_APP_ALCHEMY_KEY;<br>const { createAlchemyWeb3 } = require(&quot;<a href="http://twitter.com/alch/alchemy-web3">@alch/alchemy-web3</a>&quot;);<br>const web3 = createAlchemyWeb3(alchemyKey);</pre><p>ℹ️ <strong>INFO: </strong><a href="https://github.com/alchemyplatform/alchemy-web3">Alchemy Web3</a> is a wrapper around <a href="https://web3js.readthedocs.io/en/v1.2.9/">Web3.js</a>, providing enhanced API methods and other crucial benefits to make your life as a web3 developer easier. It is designed to require minimal configuration so you can start using it in your app right away!</p><p>Next, let’s add our contract ABI and contract address to our file.</p><pre>require(&#39;dotenv&#39;).config();<br>const alchemyKey = process.env.REACT_APP_ALCHEMY_KEY;<br>const { createAlchemyWeb3 } = require(&quot;<a href="http://twitter.com/alch/alchemy-web3">@alch/alchemy-web3</a>&quot;);<br>const web3 = createAlchemyWeb3(alchemyKey);</pre><pre>const contractABI = require(&#39;../contract-abi.json&#39;)<br>const contractAddress = &quot;0x4C4a07F737Bf57F6632B6CAB089B78f62385aCaE&quot;;</pre><p>Once we have both of those, we’re ready to start coding our mint function!</p><h3>Step 8: Implement the mintNFT function</h3><p>Inside your interact.js file, let&#39;s define our function, mintNFT , which eponymously will mint our NFT.</p><p>Because we will be making numerous asynchronous calls (to Pinata to pin our metadata to IPFS, Alchemy Web3 to load our smart contract, and Metamask to sign our transactions), our function will also be asynchronous.</p><p>The three inputs to our function will be the url of our digital asset, name, and description. Add the following function signature below the connectWallet function:</p><pre>export const mintNFT = async(url, name, description) =&gt; {<br>}</pre><h4>Input error handling</h4><p>Naturally, it makes sense to have some sort of input error handling at the start of the function, so we exit this function if our input parameters aren’t correct. Inside our function, let’s add the following code:</p><pre>export const mintNFT = async(url, name, description) =&gt; {<br> //error handling<br> if (url.trim() == &quot;&quot; || (name.trim() == &quot;&quot; || description.trim() == &quot;&quot;)) { <br>   return {<br>    success: false,<br>    status: &quot;❗Please make sure all fields are completed before minting.&quot;,<br>   }<br>  }<br>}</pre><p>Essentially, if any of the input parameters are an empty string, then we return a JSON object where the success boolean is false, and the status string relays that all fields in our UI must be complete.</p><h4>Upload the metadata to IPFS</h4><p>Once we know our metadata is formatted properly, the next step is to wrap it into a JSON object and upload it to IPFS via the pinJSONToIPFS we wrote!</p><p>To do so, we first we need to import the pinJSONToIPFSfunction into our interact.js file. At the very top of the interact.js, let&#39;s add:</p><pre>import {pinJSONToIPFS} from &#39;./pinata.js&#39;</pre><p>Recall, that pinJSONToIPFS takes in a JSON body. So before we make a call to it, we&#39;re going to need to format our url, name, and description parameters into a JSON object.</p><p>Let’s update our code to create a JSON object called metadata and then make a call to pinJSONToIPFS with this metadata parameter:</p><pre>export const mintNFT = async(url, name, description) =&gt; {<br> //error handling<br> if (url.trim() == &quot;&quot; || (name.trim() == &quot;&quot; || description.trim() == &quot;&quot;)) { <br>        return {<br>            success: false,<br>            status: &quot;❗Please make sure all fields are completed before minting.&quot;,<br>        }<br>  }<br> <br>  //make metadata<br>  const metadata = new Object();<br>  metadata.name = name;<br>  metadata.image = url;<br>  metadata.description = description;<br>  <br>  //make pinata call<br>  const pinataResponse = await pinJSONToIPFS(metadata);<br>  if (!pinataResponse.success) {<br>      return {<br>          success: false,<br>          status: &quot;😢 Something went wrong while uploading your tokenURI.&quot;,<br>      }<br>  } <br>  const tokenURI = pinataResponse.pinataUrl;  <br>}</pre><p>Notice, we store the response of our call to pinJSONToIPFS(metadata) in the pinataResponse object. Then, we parse this object for any errors.</p><p>If there’s an error, we return a JSON object where the success boolean is false and our status string relays that our call failed. Otherwise, we extract the pinataURL from the pinataResponse and store it as our tokenURIvariable.</p><p>Now it’s time to load our smart contract using the Alchemy Web3 API that we initialized at the top of our file. Add the following line of code to the bottom of the mintNFT function to set the contract at the window.contract global variable:</p><pre>window.contract = await new web3.eth.Contract(contractABI, contractAddress);</pre><p>The last thing to add in our mintNFT function is our Ethereum transaction:</p><pre>//set up your Ethereum transaction<br> const transactionParameters = {<br>        to: contractAddress, // Required except during contract publications.<br>        from: window.ethereum.selectedAddress, // must match user&#39;s active address.<br>        &#39;data&#39;: window.contract.methods.mintNFT(window.ethereum.selectedAddress, tokenURI).encodeABI()//make call to NFT smart contract <br> };<br>    <br>//sign the transaction via Metamask<br> try {<br>    const txHash = await window.ethereum<br>        .request({<br>            method: &#39;eth_sendTransaction&#39;,<br>            params: [transactionParameters],<br>        });<br>    return {<br>        success: true,<br>        status: &quot;✅ Check out your transaction on Etherscan: <a href="https://ropsten.etherscan.io/tx/">https://ropsten.etherscan.io/tx/</a>&quot; + txHash<br>    }<br> } catch (error) {<br>    return {<br>        success: false,<br>        status: &quot;😥 Something went wrong: &quot; + error.message<br>    }</pre><pre>}</pre><p>If you’re already familiar with Ethereum transactions, you’ll notice that the structure is pretty similar to what you’ve seen.</p><p>First, we set up our transactions parameters.</p><ul><li>to specifies the the recipient address (our smart contract)</li><li>from specifies the signer of the transaction (the user&#39;s connected address to Metamask: window.ethereum.selectedAddress)</li><li>data contains the call to our smart contract mintNFT method, which receives our tokenURI and the user&#39;s wallet address, window.ethereum.selectedAddress, as inputs</li></ul><p>Then, we make an await call, window.ethereum.request, where we ask Metamask to sign the transaction. Notice, in this request, we&#39;re specifying our eth method (eth_SentTransaction) and passing in our transactionParameters. At this point, Metamask will open up in the browser, and prompt the user to sign or reject the transaction.</p><ul><li>If the transaction is successful, the function will return a JSON object where the boolean success is set to true and the status string prompts the user to check out Etherscan for more information about their transaction.</li><li>If the transaction fails, the function will return a JSON object where the success boolean is set to false, and the status string relays the error message.</li></ul><p>Altogether, our mintNFT function should look like this:</p><pre>export const mintNFT = async(url, name, description) =&gt; {<br>    <br>    //error handling<br>    if (url.trim() == &quot;&quot; || (name.trim() == &quot;&quot; || description.trim() == &quot;&quot;)) { <br>        return {<br>            success: false,<br>            status: &quot;❗Please make sure all fields are completed before minting.&quot;,<br>        }<br>    }<br>  <br>    //make metadata<br>    const metadata = new Object();<br>    metadata.name = name;<br>    metadata.image = url;<br>    metadata.description = description;</pre><pre>//pinata pin request<br>    const pinataResponse = await pinJSONToIPFS(metadata);<br>    if (!pinataResponse.success) {<br>        return {<br>            success: false,<br>            status: &quot;😢 Something went wrong while uploading your tokenURI.&quot;,<br>        }<br>    } <br>    const tokenURI = pinataResponse.pinataUrl;</pre><pre>//load smart contract<br>    window.contract = await new web3.eth.Contract(contractABI, contractAddress);//loadContract();</pre><pre>//set up your Ethereum transaction<br>    const transactionParameters = {<br>        to: contractAddress, // Required except during contract publications.<br>        from: window.ethereum.selectedAddress, // must match user&#39;s active address.<br>        &#39;data&#39;: window.contract.methods.mintNFT(window.ethereum.selectedAddress, tokenURI).encodeABI() //make call to NFT smart contract <br>    };<br>  <br>    //sign transaction via Metamask<br>    try {<br>        const txHash = await window.ethereum<br>            .request({<br>                method: &#39;eth_sendTransaction&#39;,<br>                params: [transactionParameters],<br>            });<br>        return {<br>            success: true,<br>            status: &quot;✅ Check out your transaction on Etherscan: <a href="https://ropsten.etherscan.io/tx/">https://ropsten.etherscan.io/tx/</a>&quot; + txHash<br>        }<br>    } catch (error) {<br>        return {<br>            success: false,<br>            status: &quot;😥 Something went wrong: &quot; + error.message<br>        }<br>    }<br>}</pre><p>That’s one giant function! Now, we just need to connect our mintNFT function to our Minter.js component...</p><h3>Step 9: Connect mintNFT to our Minter.js frontend</h3><p>Open up your Minter.js file and update the import { connectWallet } from &quot;./utils/interact.js&quot;; line at the top to be:</p><pre>import { connectWallet, mintNFT } from &quot;./utils/interact.js&quot;;</pre><p>Finally, implement the onMintPressed function to make await call to your imported mintNFTfunction and update the status state variable to reflect whether our transaction succeeded or failed:</p><pre>const onMintPressed = async () =&gt; {<br>    const { status } = await mintNFT(url, name, description);<br>    setStatus(status);<br>};</pre><p>One last step…</p><h3>Step 10: Take the blockchain world by storm 🚀</h3><p>JK, you made it to the end of the tutorial! To recap, by building an NFT minter, you successfully learned how to:</p><ul><li>Connect to Metamask via your frontend project</li><li>Call smart contract methods from your frontend</li><li>Sign transactions using Metamask</li></ul><p>Presumably, you’d like to be able to show off the NFTs minted via your dApp in your wallet — so be sure to check out our quick tutorial <a href="https://docs.alchemyapi.io/alchemy/tutorials/how-to-write-and-deploy-a-nft-smart-contract/how-to-view-your-nft-in-your-wallet">How to View Your NFT in Your Wallet</a>!</p><p>And, as always, if you have any questions, we’re here to help in the <a href="https://discord.gg/gWuC7zB">Alchemy Discord</a>. We can’t wait to see how you apply the concepts from this tutorial to your future projects! 🧙‍♂️</p><h3>Bonus: Put your NFT Minter to work!</h3><p>Ready to mint an NFT using your minter? Check out this demo video!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FmmrO6_5-hRU%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DmmrO6_5-hRU&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FmmrO6_5-hRU%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/54e89f8bdd2fd4f9aa86bb5766914e80/href">https://medium.com/media/54e89f8bdd2fd4f9aa86bb5766914e80/href</a></iframe><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:8475f0fd-56af-4dbf-bcf2-9b379d1679e0"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c5966c3c0d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/nft-minter-tutorial-how-to-create-a-full-stack-dapp-3c5966c3c0d6">📝 NFT Minter Tutorial: How to Create a Full Stack DApp</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Ready for Ethereum’s Berlin Hard Fork]]></title>
            <link>https://medium.com/alchemy-api/getting-ready-for-ethereums-berlin-hard-fork-3afd07458532?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3afd07458532</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[berlin]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Tue, 13 Apr 2021 20:57:35 GMT</pubDate>
            <atom:updated>2021-04-13T20:57:35.399Z</atom:updated>
            <content:encoded><![CDATA[<p><em>If you’re an Alchemy user, you can stop reading here! We’ve got you covered. If you’re not using us or if you’re interested in fork details, best practices, and how we handle things for you, read on!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pk0Pg-fu4feVOrMh.png" /></figure><p>This Wednesday, April 14, 2021, the Ethereum Foundation’s <a href="https://blog.ethereum.org/2021/03/08/ethereum-berlin-upgrade-announcement/">Berlin<em> </em>hard fork</a> upgrade is scheduled to go live on Mainnet at block 12,244,000.</p><p>The system-wide upgrade will introduce four Ethereum Improvement Proposals (EIPs), namely <a href="https://eips.ethereum.org/EIPS/eip-2565">2565</a>, <a href="https://eips.ethereum.org/EIPS/eip-2718">2718</a>, <a href="https://eips.ethereum.org/EIPS/eip-2929">2929</a>, and <a href="https://eips.ethereum.org/EIPS/eip-2930">2930</a>, which are part of a larger roadmap towards Ethereum 2.0.</p><h3><strong>So what does that mean for me?</strong></h3><p>If you’re using <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aed2ba93-969a-4812-ab81-27928b15db31">Alchemy</a> as your Ethereum node provider, then you don’t need to do anything!</p><p>As the leading blockchain developer platform, our job is to handle all the complicated Ethereum infrastructure, so you can focus on building your application instead of running, maintaining, and upgrading nodes.</p><p>Our team has been preparing for this upgrade for months — with release notes audits, regression testing, blue green deploys, <a href="https://medium.com/alchemy-api/dont-get-forked-best-practices-for-handling-constantinople-and-ethereum-client-upgrades-e0d6b5dd8e9c">and more</a> — so you have a seamless transition when this upgrade occurs.</p><p>If you’re <em>not</em> using Alchemy, then it’s SUPER important that you update your node to a Berlin compatible version, otherwise it’ll be incompatible with the rest of the network past block 12,244,000.</p><p>On the Ethereum’s Foundation’s <a href="https://blog.ethereum.org/2021/03/08/ethereum-berlin-upgrade-announcement/">announcement of the upgrade</a>, they’ve listed the client versions compatible with the Berlin update. We’ve added them below for your convenience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*qaPKudxy5dlNhuxw" /><figcaption>Berlin update’s compatible Ethereum client versions</figcaption></figure><h3><strong>Are there any best practices I should consider?</strong></h3><p>Glad you asked. Highly recommend you check out <a href="https://medium.com/alchemy-api/dont-get-forked-best-practices-for-handling-constantinople-and-ethereum-client-upgrades-e0d6b5dd8e9c">this blog post</a> on best practices we wrote during the Constantinople hard fork.</p><p>For the Berlin hard fork specifically, it’s important to ensure that your transactions are <a href="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a> compatible to protect against replay attacks. Following the Berlin upgrade, geth clients will default to enforcing EIP-155 compatibility, meaning your transitions will fail if they do not comply with the EIP.</p><p>At the time of writing, Alchemy still supports pre-EIP-155 unprotected transactions (we’ll give our users plenty of warning before it becomes a requirement), but it’s great practice to get into the habit of formatting EIP-155 compatible requests.</p><h3><strong>What happens if I don’t participate in the upgrade?</strong></h3><p>This is a bad idea. Your client will remain synced to the pre-forked blockchain after the update happens. So, you’ll be stuck on a deprecated chain and unable to transfer ether or interact with the post-upgrade Ethereum network.</p><h3><strong>What are the new EIPs in this upgrade?</strong></h3><p>Below is a quick description of each of these EIPS from the the Ethereum Foundation:</p><ul><li><a href="https://eips.ethereum.org/EIPS/eip-2565">EIP-2565: ModExp Gas Cost</a> lowers the cost of <a href="https://eips.ethereum.org/EIPS/eip-198">modular exponentiation</a> (ModExp 0x00..05) precompile, making it a similar cost to other operations.</li><li><a href="https://eips.ethereum.org/EIPS/eip-2718">EIP-2718: Typed Transaction Envelope</a> introduces a new transaction type that is an envelope to enable easier support for multiple transaction types.</li><li><a href="https://eips.ethereum.org/EIPS/eip-2929">EIP-2929: Gas cost increases for state access opcodes</a> increases gas cost for SLOAD, *CALL, BALANCE, EXT* and SELFEDESTRUCT when used for the first time in a transaction, after the first call the gas costs are fixed.</li><li><a href="https://eips.ethereum.org/EIPS/eip-2930">EIP-2930: Optional access lists</a> adds a transaction type which contains an access list, a list of addresses and storage keys that the transaction plans to access. This mitigates some of the gas cost increases introduced by EIP-2929.</li></ul><h3><strong>Never worry about hard forks again…</strong></h3><p>If you’re working on an Ethereum project and don’t want to deal with the overhead of maintaining nodes, <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aed2ba93-969a-4812-ab81-27928b15db31">sign up for Alchemy for free</a>! Alchemy provides the fastest, most scalable, and most reliable Ethereum infrastructure as a service so that you can focus on building your product. Under the hood, we’ve built revolutionary new infrastructure that’s powering all the leading NFT developer platforms, the majority of DeFi, and more! Learn more at <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aed2ba93-969a-4812-ab81-27928b15db31">alchemyapi.io</a>.</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aed2ba93-969a-4812-ab81-27928b15db31"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3afd07458532" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/getting-ready-for-ethereums-berlin-hard-fork-3afd07458532">Getting Ready for Ethereum’s Berlin Hard Fork</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Alchemy Teams Up with Fei Labs to Accelerate Adoption of the Most Anticipated Stablecoin Platform]]></title>
            <link>https://medium.com/alchemy-api/alchemy-teams-up-with-fei-labs-to-accelerate-adoption-of-the-most-anticipated-stablecoin-platform-27f8b9912e8a?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/27f8b9912e8a</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[stablecoin-cryptocurrency]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[fei]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Thu, 01 Apr 2021 17:42:36 GMT</pubDate>
            <atom:updated>2021-06-30T23:51:08.700Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Blockchain developer platform, </em><a href="https://www.alchemyapi.io/"><em>Alchemy</em></a><em>, has integrated its supercharged Ethereum API and essential developer tools into </em><a href="https://fei.money/"><em>Fei Labs</em></a><em>, as they aim to be the stablecoin for DeFi users around the world.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HqG3uwZGdvNP1N0OAv_6hA.jpeg" /></figure><p>With the kick-off of Fei Protocol’s genesis this week, the core development team is well on its way to having solved the single most important aspect of DeFi — access to a “decentralized, fair, liquid, and scalable stablecoin.” The Protocol’s new elegant mechanism of “direct incentives” may finally be the stability mechanism that offers a high fidelity peg. A solution of this magnitude would propel the entire ecosystem forward, something that Fei Labs’s recent backers like a16z (Andreessen Horowitz) and Coinbase Ventures also recognize.</p><p>As ecosystem builders powering the majority of DeFi applications, the Alchemy Platform is continuously looking to partner with teams that are solving some of the biggest challenges in the ecosystem. That’s why Alchemy is super excited to announce our partnership with Fei Labs!</p><p>“Fei Labs’s unique solution to the notorious stablecoin problem could be one of the most important innovations for DeFi applications. The core Fei team, Joey, Seb, and Brianna, are a talented team, eager to see the vision come to life. I’m super excited to see all the awesome products their team ships for the ecosystem,” said Paul Almasi, Co-Creator of <a href="https://www.alchemyapi.io/amplify">Alchemy Amplify</a> (an E&amp;P Production).</p><p>With Fei Labs leveraging Alchemy’s best-in-class platform, they will have access to one of the most scalable Ethereum API, empowering Fei Labs to bring the ultimate DeFi user experience to everyone around the world.</p><p>“Building in Web 3.0 is generally difficult, especially in terms of tight timelines and the size of the launch of Fei Labs. Alchemy has not only the best in-class solution, but they are also there to support Fei Protocol as if they were an extension of core dev team, which is invaluable to us as we look to be the stablecoin of DeFi and beyond.” — Sebastian Delgado, Co-founder of Fei Protocol.</p><p>While the Fei Team is pushing the boundaries of what is possible with stablecoins, Alchemy is here to support them with a platform meant to help DeFi developers reshape how humanity interacts with money.</p><p><strong>About Fei Labs</strong></p><p>Fei Labs is the team that created FEI, a highly scalable, decentralized, and reserve-backed stablecoin that can meet DeFi’s needs without relying on centralized assets for collateral, that unlocks next-generation integration potential. Our mission is to be the stable coin of DeFi backed by some of the top minds in the space, including a16z, Nascent, Variant, Coinbase,</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:b6347e30-4a26-426f-bf59-2370d38fcb47"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $22 billion in on-chain transactions and has been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em>, and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong><em>Sign up for a </em></strong><a href="https://dashboard.alchemyapi.io/signup/"><strong><em>free account</em></strong></a><strong><em>. Check out our </em></strong><a href="https://docs.alchemyapi.io/"><strong><em>documentation</em></strong></a><strong><em>. For the latest news, follow us on </em></strong><a href="https://twitter.com/AlchemyPlatform"><strong><em>Twitter</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27f8b9912e8a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/alchemy-teams-up-with-fei-labs-to-accelerate-adoption-of-the-most-anticipated-stablecoin-platform-27f8b9912e8a">Alchemy Teams Up with Fei Labs to Accelerate Adoption of the Most Anticipated Stablecoin Platform</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to View Your NFT in Your Wallet]]></title>
            <link>https://medium.com/alchemy-api/how-to-view-your-nft-in-your-wallet-f774f4286e2?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f774f4286e2</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Fri, 12 Mar 2021 18:44:56 GMT</pubDate>
            <atom:updated>2021-03-18T20:31:02.014Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This tutorial describes how to view an existing an NFT on your virtual Ethereum wallet (Metamask in this case)! If you’d like to learn how to mint your own NFT on Ethereum, you should check out our guide on </em><a href="https://medium.com/alchemy-api/how-to-write-deploy-an-nft-d92c8b6b777f"><em>How to Create an NFT</em></a><em> smart contract!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9ETalvMKJyW3vPGmgZ-Nw.png" /></figure><p>Congrats! You’ve made it to the shortest and simplest part of our NFT tutorial series — how to view your freshly minted NFT on a virtual wallet. We’ll be using Metamask for this example since it is what we used in the previous two parts.</p><p>As a prerequisite, you should already have Metamask on mobile installed, and it should include the account to which you minted your NFT — you can get the app for free on <a href="https://apps.apple.com/us/app/metamask-blockchain-wallet/id1438144202">iOS</a> or <a href="https://play.google.com/store/apps/details?id=io.metamask&amp;hl=en_US&amp;gl=US">Android</a> .</p><h3>Step 1: Set your network to Ropsten</h3><p>At the top of the app, press the “Wallet” button, after which you’ll be prompted to select a network. As our NFT was minted on the Ropsten network, you’ll want to select Ropsten as your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/0*TNkHv5vg4lYBM41n.gif" /><figcaption>How to set Ropsten as your network on Metamask Mobile</figcaption></figure><h3>Step 2: Add your collectable to Metamask</h3><p>Once you’re on the Ropsten network, select the “Collectibles” tab on the right and add the NFT smart contract address and the ERC-721 token ID of your NFT — which you should be able to find on Etherscan based on the transaction hash from your NFT deployed in Part II of our tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yIrsddEy2WdAtU3o.png" /><figcaption>How to find your transaction hash and ERC-721 token ID</figcaption></figure><p>You may need to refresh a couple times to view your NFT — but it will be there! 😄</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/0*GWLAVBfpxo_W0_02.gif" /><figcaption>How to upload your NFT to metamask</figcaption></figure><p>Congrats! You have successfully minted an NFT, and you can now view it! We can’t wait to see how you’ll take the NFT world by storm! 🧸🪄🧙🤑🎊</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aab0c546-cc29-4180-8d31-fbce31367277"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide and the biggest players in the NFT space, including OpenSea, Nifty Gateway, Makersplace, Dapper Labs, Zora, NFTfi, Super Rare, Foundation, Enjin, Origin Protocol, Immutable, and more. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f774f4286e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/how-to-view-your-nft-in-your-wallet-f774f4286e2">How to View Your NFT in Your Wallet</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Mint an NFT]]></title>
            <link>https://medium.com/alchemy-api/how-to-mint-an-nft-8cd51e8eb634?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cd51e8eb634</guid>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Fri, 12 Mar 2021 18:36:02 GMT</pubDate>
            <atom:updated>2021-03-18T20:30:17.413Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This tutorial describes how to mint an NFT on the Ethereum blockchain using our smart contract and Web3. You should have already completed Part I: </em><a href="https://medium.com/alchemy-api/how-to-write-deploy-an-nft-d92c8b6b777f"><em>How to Create an NFT,</em></a><em> prior to starting Part II below. In Part III, we will explain how to </em><a href="https://medium.com/alchemy-api/how-to-view-your-nft-in-your-wallet-f774f4286e2"><em>view your freshly minted NFT on Metamask</em></a><em>!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9ETalvMKJyW3vPGmgZ-Nw.png" /></figure><p><a href="https://www.wsj.com/articles/beeple-nft-fetches-record-breaking-69-million-in-christies-sale-11615477732">Beeple</a>: $69 Million<br><a href="https://www.forbes.com/sites/abrambrown/2021/03/03/3lau-nft-nonfungible-tokens-justin-blau/?sh=5f72ef64643b">3LAU</a>: $11 Million<br><a href="https://www.theguardian.com/music/2021/mar/02/grimes-sells-digital-art-collection-non-fungible-tokens">Grimes</a>: $6 Million</p><p>All of them minted their NFT’s using Alchemy’s powerful API. In this tutorial, we’ll teach you how to the same in &lt;10 minutes.</p><p>“Minting a NFT” is the act of publishing a unique instance of your ERC721 token on the blockchain. Using our <a href="https://medium.com/alchemy-api/how-to-write-deploy-an-nft-d92c8b6b777f">smart contract from Part I of this NFT tutorial series</a>, let’s flex our web3 skills and mint a NFT. At the end of this tutorial, you’ll be able to mint as many NFTs as your heart (and wallet) desires!</p><p>Let’s get started! 🪄</p><h3>Step 1: Install web3</h3><p>If you followed the first tutorial on <a href="https://medium.com/alchemy-api/how-to-write-deploy-an-nft-d92c8b6b777f">creating your NFT smart contract</a>, you already have experience using Ethers.js. Web3 is similar to Ethers, as it is a library used to make creating requests to the Ethereum blockchain easier. In this tutorial we’ll be using <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-web3">Alchemy Web3</a>, which is an enhanced web3 library that offers automatic retries and robust WebSocket support.</p><p>In your project home directory run:</p><pre>npm install @alch/alchemy-web3</pre><h3>Step 2: Create a mint-nft.js file</h3><p>Inside your scripts directory, create an mint-nft.js file and add the following lines of code:</p><pre>require(&#39;dotenv&#39;).config();<br>const API_URL = process.env.API_URL;<br>const { createAlchemyWeb3 } = require(&quot;@alch/alchemy-web3&quot;);<br>const web3 = createAlchemyWeb3(API_URL);</pre><h3>Step 3: Grab your contract ABI</h3><p>Our contract ABI (Application Binary Interface) is the interface to interact with our smart contract. You can learn more about Contract ABIs <a href="https://docs.alchemyapi.io/alchemy/guides/eth_getlogs#what-are-ab-is">here</a>. Hardhat automatically generates an ABI for us and saves it in the MyNFT.json file. In order to use this we’ll need to parse out the contents by adding the following lines of code to our mint-nft.js file:</p><pre>const contract = require(&quot;../artifacts/contracts/MyNFT.sol/MyNFT.json&quot;);</pre><p>If you want to see the ABI you can print it to your console:</p><pre>console.log(JSON.stringify(contract.abi));</pre><p>To run mint-nft.jsand see your ABI printed to the console navigate to your terminal and run</p><pre>node scripts/mint-nft.js</pre><h3>Step 4: Configure the metadata for your NFT using IPFS</h3><p>If you remember from our tutorial in Part 1, our mintNFT smart contract function takes in a tokenURI parameter that should resolve to a JSON document describing the NFT&#39;s metadata— which is really what brings the NFT to life, allowing it to have configurable properties, such as a name, description, image, and other attributes.</p><blockquote><em>Interplanetary File System (IPFS) is a decentralized protocol and peer-to-peer network for storing and sharing data in a distributed file system.</em></blockquote><p>We will use Pinata, a convenient IPFS API and toolkit, to store our NFT asset and metadata to ensure our NFT is truly decentralized. If you don’t have a Pinata account, sign up for a free account <a href="https://pinata.cloud/signup">here</a> and complete the steps to verify your email.</p><p>Once you’ve created an account:</p><ul><li>Navigate to the “Pinata Upload” button on the top right</li><li>Upload an image to pinata — this will be the image asset for your NFT. Feel free to name the asset whatever you wish</li><li>After you upload, at the top of the page, there should be a green popup that allows you to view the hash of your upload → Copy that hashcode. You can view your upload at: <a href="https://gateway.pinata.cloud/ipfs/QmarPqdEuzh5RsWpyH2hZ3qSXBCzC5RyK3ZHnFkAsk7u2f">https://gateway.pinata.cloud/ipfs/&lt;</a>hash-code&gt;</li></ul><p>For the more visual learners, the steps above are summarized here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*V_-3PGxnfsnLTGo4.gif" /><figcaption>How to upload your image to Pinata</figcaption></figure><p>Now, we’re going to want to upload one more document to Pinata. But before we do that, we need to create it!</p><p>In your root directory, make a new file called nft-metadata.json and add the following json code:</p><pre>{<br>    &quot;attributes&quot; : [ {<br>      &quot;trait_type&quot; : &quot;Breed&quot;,<br>      &quot;value&quot; : &quot;Maltipoo&quot;<br>    }, {<br>      &quot;trait_type&quot; : &quot;Eye color&quot;,<br>      &quot;value&quot; : &quot;Mocha&quot;<br>    } ],<br>    &quot;description&quot; : &quot;The world&#39;s most adorable and sensitive pup.&quot;,<br>    &quot;image&quot; : &quot;https://gateway.pinata.cloud/ipfs/QmWmvTJmJU3pozR9ZHFmQC2DNDwi2XJtf3QGyYiiagFSWb&quot;,<br>    &quot;name&quot; : &quot;Ramses&quot;<br>}</pre><p>Feel free to change the data in the json. You can remove or add to the attributes section. Most importantly, make sure image field points to the location of your IPFS image — otherwise, your NFT will include a photo of a (very cute!) dog.</p><p>Once you’re done editing the json file, save it and upload it to Pinata, following the same steps we did for uploading the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*eFbjFolSc50YMBmO.gif" /><figcaption>How to upload your nft-metadata.json to Pinata</figcaption></figure><h3>Step 5: Create an instance of your contract</h3><p>Now, to interact with our contract, we need to create an instance of it in our code. To do so we’ll need our contract address which we can get from the deployment or <a href="https://ropsten.etherscan.io/">Etherscan</a> by looking up the address you used to deploy the contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kLL79TiiBrOHjBQR.png" /><figcaption>View your contract address on Etherscan</figcaption></figure><p>In the above example, our contract address is 0x81c587EB0fE773404c42c1d2666b5f557C470eED.</p><p>Next we will use the web3 <a href="https://web3js.readthedocs.io/en/v1.2.0/web3-eth-contract.html?highlight=constructor#web3-eth-contract">contract method</a> to create our contract using the ABI and address. In your mint-nft.js file, add the following:</p><pre>const contractAddress = &quot;0x81c587EB0fE773404c42c1d2666b5f557C470eED&quot;;</pre><pre>const nftContract = new web3.eth.Contract(contract.abi, contractAddress);</pre><h3>Step 6: Update the .env file</h3><p>Now, in order to create and send transactions to the Ethereum chain, we’ll use your public ethereum account address to get the account nonce (will explain below).</p><p>Add your public key to your .env file —if you completed part 1 of the tutorial, our .env file should now look like this:</p><pre>API_URL = &quot;https://eth-ropsten.alchemyapi.io/v2/your-api-key&quot;<br>PRIVATE_KEY = &quot;your-private-account-address&quot;<br>PUBLIC_KEY = &quot;your-public-account-address&quot;</pre><h3>Step 7: Create your transaction</h3><p>First, let’s define a function called mintNFT(tokenData) and create our transaction by doing the following:</p><ol><li>Grab your PRIVATE_KEY<em> </em>and<em> </em>PUBLIC_KEY from the .env file.</li><li>Next, we’ll need to figure out the account nonce. The nonce specification is used to keep track of the number of transactions sent from your address— which we need for security purposes and to prevent <a href="https://docs.alchemyapi.io/alchemy/resources/blockchain-glossary#account-nonce">replay attacks</a>. To get the number of transactions sent from your address, we use <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_gettransactioncount">getTransactionCount</a>.</li><li>Finally we’ll set up our transaction with the following info:</li></ol><ul><li>&#39;from&#39;: PUBLIC_KEY : The origin of our transaction is our public address</li><li>&#39;to&#39;: contractAddress : The contract we wish to interact with and send the transaction</li><li>&#39;nonce&#39;: nonce : The account nonce with the number of transactions send from our address</li><li>&#39;gas&#39;: estimatedGas : The estimated gas needed to complete the transaction</li><li>&#39;data&#39;: nftContract.methods.mintNFT(PUBLIC_KEY, md).encodeABI() : The computation we wish to perform in this transaction— which in this case is minting a NFT</li></ul><p>Your mint-nft.js file should look like this now:</p><pre>require(&#39;dotenv&#39;).config();<br>const API_URL = process.env.API_URL;<br>const PUBLIC_KEY = process.env.PUBLIC_KEY;<br>const PRIVATE_KEY = process.env.PRIVATE_KEY;</pre><pre>const { createAlchemyWeb3 } = require(&quot;@alch/alchemy-web3&quot;);<br>const web3 = createAlchemyWeb3(API_URL);</pre><pre>const contract = require(&quot;../artifacts/contracts/MyNFT.sol/MyNFT.json&quot;);<br>const contractAddress = &quot;0x81c587EB0fE773404c42c1d2666b5f557C470eED&quot;;<br>const nftContract = new web3.eth.Contract(contract.abi, contractAddress);</pre><pre>async function mintNFT(tokenURI) {<br>  const nonce = await web3.eth.getTransactionCount(PUBLIC_KEY, &#39;latest&#39;); //get latest nonce</pre><pre>//the transaction<br>  const tx = {<br>    &#39;from&#39;: PUBLIC_KEY,<br>    &#39;to&#39;: contractAddress,<br>    &#39;nonce&#39;: nonce,<br>    &#39;gas&#39;: 500000,<br>    &#39;data&#39;: nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()<br>  };<br>}​</pre><h3>Step 8: Sign the transaction</h3><p>Now that we’ve created our transaction, we need to sign it in order to send it off. Here is where we’ll use our private key.</p><p>web3.eth.sendSignedTransaction will give us the transaction hash, which we can use to make sure our transaction was mined and didn&#39;t get dropped by the network. You&#39;ll notice in the transaction signing section, we&#39;ve added some error checking so we know if our transaction successfully went through.</p><pre>require(&#39;dotenv&#39;).config();<br>const API_URL = process.env.API_URL;<br>const PUBLIC_KEY = process.env.PUBLIC_KEY;<br>const PRIVATE_KEY = process.env.PRIVATE_KEY;</pre><pre>const { createAlchemyWeb3 } = require(&quot;@alch/alchemy-web3&quot;);<br>const web3 = createAlchemyWeb3(API_URL);</pre><pre>const contract = require(&quot;../artifacts/contracts/MyNFT.sol/MyNFT.json&quot;);<br>const contractAddress = &quot;0x81c587EB0fE773404c42c1d2666b5f557C470eED&quot;;<br>const nftContract = new web3.eth.Contract(contract.abi, contractAddress);</pre><pre>async function mintNFT(tokenURI) {<br>  const nonce = await web3.eth.getTransactionCount(PUBLIC_KEY, &#39;latest&#39;); //get latest nonce</pre><pre>//the transaction<br>  const tx = {<br>    &#39;from&#39;: PUBLIC_KEY,<br>    &#39;to&#39;: contractAddress,<br>    &#39;nonce&#39;: nonce,<br>    &#39;gas&#39;: 500000,<br>    &#39;data&#39;: nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()<br>  };</pre><pre>const signPromise = web3.eth.accounts.signTransaction(tx, PRIVATE_KEY);<br>  signPromise.then((signedTx) =&gt; {</pre><pre>web3.eth.sendSignedTransaction(signedTx.rawTransaction, function(err, hash) {<br>      if (!err) {<br>        console.log(&quot;The hash of your transaction is: &quot;, hash, &quot;\nCheck Alchemy&#39;s Mempool to view the status of your transaction!&quot;); <br>      } else {<br>        console.log(&quot;Something went wrong when submitting your transaction:&quot;, err)<br>      }<br>    });<br>  }).catch((err) =&gt; {<br>    console.log(&quot; Promise failed:&quot;, err);<br>  });<br>}</pre><h3>Step 9: Call mintNFT and run node contract-interact.js</h3><p>Remember the metadata.json you uploaded to Pinata? Get its hashcode from Pinata and pass the following into a call to mintNFT <a href="https://gateway.pinata.cloud/ipfs/&lt;hash-code&gt;">https://gateway.pinata.cloud/ipfs/&lt;metadata-hash-code&gt;</a></p><p>Here’s how to get the hashcode:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/0*auhWUQs1tfT5tiar.gif" /><figcaption>How to get your nft metadata hashcode on Pinata</figcaption></figure><blockquote>Double check that the hashcode you copied links to your <strong>metadata.json</strong> by loading <a href="https://gateway.pinata.cloud/ipfs/%3Chash-code%3E">https://gateway.pinata.cloud/ipfs/&lt;metadata-hash-code&gt;</a> into a separate window. The page should look similar to the screenshot below:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I52WF3hN76kPX4An" /><figcaption>Your page should display the json metadata</figcaption></figure><p>Altogether, your code should look something like this:</p><pre>require(&#39;dotenv&#39;).config();<br>const API_URL = process.env.API_URL;<br>const PUBLIC_KEY = process.env.PUBLIC_KEY;<br>const PRIVATE_KEY = process.env.PRIVATE_KEY;</pre><pre>const { createAlchemyWeb3 } = require(&quot;@alch/alchemy-web3&quot;);<br>const web3 = createAlchemyWeb3(API_URL);</pre><pre>const contract = require(&quot;../artifacts/contracts/MyNFT.sol/MyNFT.json&quot;);<br>const contractAddress = &quot;0x81c587EB0fE773404c42c1d2666b5f557C470eED&quot;;<br>const nftContract = new web3.eth.Contract(contract.abi, contractAddress);</pre><pre>async function mintNFT(tokenURI) {<br>  const nonce = await web3.eth.getTransactionCount(PUBLIC_KEY, &#39;latest&#39;); //get latest nonce</pre><pre>//the transaction<br>  const tx = {<br>    &#39;from&#39;: PUBLIC_KEY,<br>    &#39;to&#39;: contractAddress,<br>    &#39;nonce&#39;: nonce,<br>    &#39;gas&#39;: 500000,<br>    &#39;data&#39;: nftContract.methods.mintNFT(PUBLIC_KEY, tokenURI).encodeABI()<br>  };</pre><pre>const signPromise = web3.eth.accounts.signTransaction(tx, PRIVATE_KEY);<br>  signPromise.then((signedTx) =&gt; {</pre><pre>web3.eth.sendSignedTransaction(signedTx.rawTransaction, function(err, hash) {<br>      if (!err) {<br>        console.log(&quot;The hash of your transaction is: &quot;, hash, &quot;\nCheck Alchemy&#39;s Mempool to view the status of your transaction!&quot;); <br>      } else {<br>        console.log(&quot;Something went wrong when submitting your transaction:&quot;, err)<br>      }<br>    });<br>  }).catch((err) =&gt; {<br>    console.log(&quot; Promise failed:&quot;, err);<br>  });<br>}</pre><pre>mintNFT(&quot;https://gateway.pinata.cloud/ipfs/QmYueiuRNmL4MiA2GwtVMm6ZagknXnSpQnB3z2gWbz36hP&quot;)</pre><p>Now, run node scripts/mint-nft.js to deploy your NFT. After a couple of seconds, you should see a response like this in your terminal:</p><pre>The hash of your transaction is: 0x10e5062309de0cd0be7edc92e8dbab191aa2791111c44274483fa766039e0e00</pre><pre>Check Alchemy&#39;s Mempool to view the status of your transaction!</pre><p>Next, visit your <a href="https://dashboard.alchemyapi.io/mempool">Alchemy mempool</a> to see the status of your transaction (whether it’s pending, mined, or got dropped by the network). If your transaction got dropped, it’s also helpful to check <a href="https://ropsten.etherscan.io/">Ropsten Etherscan</a> and search for your transaction hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Q7IfLIhtVnNtAJn-.png" /><figcaption>View your NFT transaction hash on Etherscan</figcaption></figure><p>And that’s it! You’ve now deployed AND minted with a NFT on the Ethereum blockchain 🤑</p><p>Using the mint-nft.js you can mint as many NFT&#39;s as your heart (and wallet) desires! Just be sure to pass in a new tokenURI describing the NFT&#39;s metadata (otherwise, you&#39;ll just end up making a bunch of identical ones with different IDs).</p><p>Presumably, you’d like to be able to show off your NFT in your wallet — so be sure to check out <a href="https://medium.com/alchemy-api/how-to-view-your-nft-in-your-wallet-f774f4286e2">Part III: How to View Your NFT in Your Wallet</a>!</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aab0c546-cc29-4180-8d31-fbce31367277"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide and the biggest players in the NFT space, including OpenSea, Nifty Gateway, Makersplace, Dapper Labs, Zora, NFTfi, Super Rare, Foundation, Enjin, Origin Protocol, Immutable, and more. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cd51e8eb634" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/how-to-mint-an-nft-8cd51e8eb634">How to Mint an NFT</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create an NFT]]></title>
            <link>https://medium.com/alchemy-api/how-to-write-deploy-an-nft-d92c8b6b777f?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d92c8b6b777f</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[nft-collectibles]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Fri, 12 Mar 2021 18:22:54 GMT</pubDate>
            <atom:updated>2021-03-24T22:39:48.668Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This tutorial is Part I of a series on NFTs that will take you step by step on how to write and deploy a Non Fungible Token (ERC721 token) smart contract using Ethereum and Inter Planetary File System (IPFS). In Part II, we will describe </em><a href="https://medium.com/alchemy-api/how-to-mint-an-nft-8cd51e8eb634"><em>how to mint an NFT</em></a><em> using our smart contract, and in Part III, we will explain how to </em><a href="https://medium.com/alchemy-api/how-to-view-your-nft-in-your-wallet-f774f4286e2"><em>view your freshly minted NFT on Metamask</em></a><em>!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9ETalvMKJyW3vPGmgZ-Nw.png" /></figure><p>Even if you’ve been living under a rock, you’ll have noticed that every major news outlet has been profiling the rise of NFTs in the past few weeks.</p><p>Alchemy is extremely proud to be powering the biggest names in the NFT space, including Makersplace (recently set a record digital artwork sale at Christie’s for $69 Million), Dapper Labs (creators of NBA Top Shot &amp; Crypto Kitties), OpenSea (the world’s largest NFT marketplace), Zora, Super Rare, NFTfi, Foundation, Enjin, Origin Protocol, Immutable, and more.</p><p>With NFTs bringing blockchain into the public eye, now is an excellent opportunity to understand the hype yourself by publishing your own NFT (ERC-721 Token) on the Ethereum blockchain!</p><p>In this tutorial, we will walk through creating and deploying an ERC-721 smart contract on the Ropsten test network using <a href="https://metamask.io/">Metamask</a>, <a href="https://docs.soliditylang.org/en/v0.8.0/">Solidity</a>, <a href="https://hardhat.org/">Hardhat</a>, <a href="https://pinata.cloud/">Pinata </a>and <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aab0c546-cc29-4180-8d31-fbce31367277">Alchemy</a> (don’t fret if you don’t understand what any of this means yet — we will explain it!).</p><p>In Part II of this tutorial we’ll go through how we can use our smart contract to mint an NFT, and in Part III we’ll explain how view your NFT on Metamask.</p><p>And of course, if you have questions at any point, don’t hesitate to reach out in the <a href="https://discord.gg/gWuC7zB">Alchemy Discord</a>!</p><h3>Step 1: Connect to the Ethereum network</h3><p>There a bunch of ways to make requests to the Ethereum blockchain, but to make things easiest, we’ll use a free account on <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aab0c546-cc29-4180-8d31-fbce31367277">Alchemy</a>, a blockchain developer platform and API that allows us to communicate with the Ethereum chain without having to run our own nodes.</p><p>In this tutorial, we’ll also take advantage of Alchemy’s developer tools for monitoring and analytics to understand what’s going on under the hood in our smart contract deployment. If you don’t already have an Alchemy account, you can sign up for free <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aab0c546-cc29-4180-8d31-fbce31367277">here</a>.</p><h3>Step 2: Create your app (and API key)</h3><p>Once you’ve created an Alchemy account, you can generate an API key by creating an app. This will allow us to make requests to the Ropsten test network. Check out <a href="https://docs.alchemyapi.io/guides/choosing-a-network">this guide</a> if you’re curious to learn more about test networks.</p><ol><li>Navigate to the “Create App” page in your Alchemy Dashboard by hovering over “Apps” in the nav bar and clicking “Create App”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XQGWtaqrAdJNm5xq.png" /><figcaption>Create your app</figcaption></figure><p>2. Name your app (we chose “My First NFT!”), offer a short description, select “Staging” for the Environment (used for your app bookkeeping), and choose “Ropsten” for your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AFYHVgRTeBsEfTPR.png" /><figcaption>Configure and publish your app</figcaption></figure><p>3. Click “Create app” and that’s it! Your app should appear in the table below.</p><h3>Step 3: Create an Ethereum account (address)</h3><p>We need an Ethereum account to send and receive transactions. For this tutorial, we’ll use Metamask, a virtual wallet in the browser used to manage your Ethereum account address. If you want to understand more about how transactions on Ethereum work, check out <a href="https://ethereum.org/en/developers/docs/transactions/">this page</a> from the Ethereum foundation.</p><p>You can download and create a Metamask account for free <a href="https://metamask.io/download.html">here</a>. When you are creating an account, or if you already have an account, make sure to switch over to the “Ropsten Test Network” in the upper right (so that we’re not dealing with real money).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*HFn3xEInPmKY6_al.png" /><figcaption>Set Ropsten as your network</figcaption></figure><p>Step 4: Add ether from a Faucet</p><p>In order to deploy our smart contract to the test network, we’ll need some fake Eth. To get Eth you can go to the <a href="https://faucet.ropsten.be/">Ropsten faucet </a>and enter your Ropsten account address, then click “Send Ropsten Eth.” You should see Eth in your Metamask account soon after!</p><h3>Step 5: Check your Balance</h3><p>To double check our balance is there, let’s make an <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_getbalance">eth_getBalance</a> request using <a href="https://composer.alchemyapi.io/?composer_state=%7B%22network%22%3A0%2C%22methodName%22%3A%22eth_getBalance%22%2C%22paramValues%22%3A%5B%22%22%2C%22latest%22%5D%7D">Alchemy’s composer tool</a>. This will return the amount of Eth in our wallet. After you input your Metamask account address and click “Send Request”, you should see a response like this:</p><pre>{&quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;id&quot;: 0, &quot;result&quot;: &quot;0xde0b6b3a7640000&quot;}</pre><p><strong>NOTE: </strong>This result is in wei not eth. Wei is used as the smallest denomination of ether. The conversion from wei to eth is: 1 eth = 1⁰¹⁸ wei. So if we convert 0xde0b6b3a7640000 to decimal we get 1*1⁰¹⁸ which equals 1 eth.</p><p>Phew! Our fake money is all there🤑 .</p><h3>Step 6: Initialize our project</h3><p>First, we’ll need to create a folder for our project. Navigate to your command line and type:</p><pre>mkdir my-nft<br>cd my-nft</pre><p>Now that we’re inside our project folder, we’ll use npm init to initialize the project. If you don’t already have npm installed, follow <a href="https://docs.alchemyapi.io/alchemy/guides/alchemy-for-macs#1-install-nodejs-and-npm">these instructions</a> (we’ll also need <a href="https://nodejs.org/en/download/">Node.js</a>, so download that too!).</p><pre>npm init</pre><p>It doesn’t really matter how you answer the installation questions, here is how we did it for reference:</p><pre>package name: (my-nft) <br>version: (1.0.0) <br>description: My first NFT!<br>entry point: (index.js) <br>test command: <br>git repository: <br>keywords: <br>author: <br>license: (ISC) <br>About to write to /Users/thesuperb1/Desktop/my-nft/package.json:</pre><pre>{<br>  &quot;name&quot;: &quot;my-nft&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;My first NFT!&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;<br>  },<br>  &quot;author&quot;: &quot;&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;<br>}</pre><p>Approve the package.json, and we’re good to go!</p><h3>Step 7: Download <a href="https://hardhat.org/getting-started/#overview">Hardhat</a></h3><p>Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software. It helps developers when building smart contracts and dApps locally before deploying to the live chain.</p><p>Inside our my-nft project run:</p><pre>npm install --save-dev hardhat</pre><p>Check out this page for more details on <a href="https://hardhat.org/getting-started/#overview">installation instructions</a>.</p><h3>Step 8: Create Hardhat project</h3><p>Inside our project folder run:</p><pre>npx hardhat</pre><p>You should then see a welcome message and option to select what you want to do. Select “create an empty hardhat.config.js”:</p><pre>888    888                      888 888               888<br>888    888                      888 888               888<br>888    888                      888 888               888<br>8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888<br>888    888     &quot;88b 888P&quot;  d88&quot; 888 888 &quot;88b     &quot;88b 888<br>888    888 .d888888 888    888  888 888  888 .d888888 888<br>888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.<br>888    888 &quot;Y888888 888     &quot;Y88888 888  888 &quot;Y888888  &quot;Y888<br>👷 Welcome to Hardhat v2.0.11 👷‍<br>? What do you want to do? …<br>Create a sample project<br>❯ Create an empty hardhat.config.js<br>Quit</pre><p>This will generate a hardhat.config.js file for us which is where we’ll specify all of the set up for our project (on step 13).</p><h3>Step 9: Add project folders</h3><p>To keep our project organized, we’ll create two new folders. Navigate to the root directory of your project in your command line and type:</p><pre>mkdir contracts<br>mkdir scripts</pre><ul><li>contracts/ is where we’ll keep our NFT smart contract code</li><li>scripts/ is where we’ll keep scripts to deploy and interact with our smart contract</li></ul><h3>Step 10: Write our contract</h3><p>Now time that our environment is set up, onto more exciting stuff: <em>writing our smart contract code!</em></p><p>Open up the my-nft project in your favorite editor (we like <a href="https://code.visualstudio.com/">VSCode</a>). Smart contracts are written in a language called Solidity which is what we will use to write our MyNFT.sol smart contract.‌</p><ol><li>Navigate to the “contracts” folder and create a new file called MyNFT.sol</li><li>Below is our NFT smart contract code, which based off of the <a href="https://docs.openzeppelin.com/contracts/3.x/erc721">OpenZepplin</a> library’s ERC721 implementation. Copy and paste the contents below into your MyNFT.sol file.</li></ol><pre>//Contract based on <a href="https://docs.openzeppelin.com/contracts/3.x/erc721">https://docs.openzeppelin.com/contracts/3.x/erc721</a><br>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.7.3;</pre><pre>import &quot;@openzeppelin/contracts/token/ERC721/ERC721.sol&quot;;<br>import &quot;@openzeppelin/contracts/utils/Counters.sol&quot;;<br>import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;<br></pre><pre>contract MyNFT is ERC721, Ownable {<br>    using Counters for Counters.Counter;<br>    Counters.Counter private _tokenIds;</pre><pre>    constructor() public ERC721(&quot;MyNFT&quot;, &quot;NFT&quot;) {}</pre><pre>    function mintNFT(address recipient, string memory tokenURI)<br>        public onlyOwner<br>        returns (uint256)<br>    {<br>        _tokenIds.increment();</pre><pre>        uint256 newItemId = _tokenIds.current();<br>        _mint(recipient, newItemId);<br>        _setTokenURI(newItemId, tokenURI);</pre><pre>        return newItemId;<br>    }<br>}</pre><p>3. Because we are inheriting classes from the OpenZepplin contracts library, in your command line run npm install @openzeppelin/contracts@3.1.0-solc-0.7to install the library into our folder.</p><p>So, what does this code <em>do</em> exactly? Let’s break it down, line by line.</p><p>At the top of our smart contract, we import three <a href="https://openzeppelin.com/">OpenZepplin</a> smart contract classes:</p><ul><li>@openzeppelin/contracts/token/ERC721/ERC721.solcontains the implementation of the ERC721 standard, which our NFT smart contract will inherit. (To be a valid NFT, your smart contract must implement all the methods of the ERC721 standard.) To learn more about the inherited ERC721 functions, check out the interface definition <a href="https://eips.ethereum.org/EIPS/eip-721">here</a>.</li><li>@openzeppelin/contracts/utils/Counters.solprovides counters that can only be incremented or decremented by one. Our smart contract uses a counter to keep track of the total number of NFTs minted and set the unique ID our new NFT. (Each NFT minted using a smart contract must be assigned a unique ID—here our unique ID is just determined by the total number of NFTs in existance. For example, the first NFT we mint with our smart contract has an ID of &quot;1,&quot; our second NFT has an ID of &quot;2,&quot; etc.)</li><li>@openzeppelin/contracts/access/Ownable.sol sets up <a href="https://docs.openzeppelin.com/contracts/3.x/access-control">access control</a> on our smart contract, so only the owner of the smart contract (you) can mint NFTs. (Note, including access control is entirely a preference. If you&#39;d like anyone to be able to mint an NFT using your smart contract, remove the word Ownable on line 10 and onlyOwner on line 17.)</li></ul><p>After our import statements, we have our custom NFT smart contract, which is surprisingly short — it only contains a counter, a constructor, and single function! This is thanks to our inherited OpenZepplin contracts, which implement most of the methods we need to create an NFT, such as ownerOf which returns the owner of the NFT, and transferFrom,which transfers ownership of the NFT from one account to another.</p><p>In our ERC721 constructor, you’ll notice we pass 2 strings, “MyNFT” and “NFT.” The first variable is the smart contract’s name, and the second is its symbol. You can name each of these variables whatever you wish!</p><p>Finally, we have our function mintNFT(address recipient, string memory tokenURI) that allows us to mint an NFT! You&#39;ll notice it this function takes in two variables:</p><ul><li>address recipient specifies the address that will receive your freshly minted NFT</li><li>string memory tokenURI is a string that should resolve to a JSON document that describes the NFT&#39;s metadata. An NFT&#39;s metadata is really what brings it to life, allowing it to have configurable properties, such as a name, description, image, and other attributes. In part 2 of this tutorial, we will describe how to configure this metadata.</li></ul><p>mintNFT calls some methods from the inherited ERC721 library, and ultimately returns a number that represents the ID of the freshly minted NFT.</p><h3>Step 11: Connect Metamask &amp; Alchemy to your project</h3><p>Now that we’ve created a Metamask wallet, Alchemy account, and written our smart contract, it’s time to connect the three.</p><p>Every transaction sent from your virtual wallet requires a signature using your unique private key. To provide our program with this permission, we can safely store our private key (and Alchemy API key) in an environment file.</p><p>To learn more about sending transactions, check out <a href="https://docs.alchemyapi.io/alchemy/tutorials/sending-transactions-using-web3-and-alchemy">this tutorial</a> on sending transactions using web3.</p><p>First, install the dotenv package in your project directory:</p><pre>npm install dotenv --save</pre><p>Then, create a .env file in the root directory of our project, and add your Metamask private key and HTTP Alchemy API URL to it.</p><ul><li>Follow <a href="https://metamask.zendesk.com/hc/en-us/articles/360015289632-How-to-Export-an-Account-Private-Key">these instructions</a> to export your private key from Metamask</li><li>See below to get HTTP Alchemy API URL and copy it to your clipboard</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/0*5dqCRVCPa3ca5-aw.gif" /><figcaption>Copy your Alchemy API URL</figcaption></figure><p>Your .env should now look like this:</p><pre>API_URL = &quot;https://eth-ropsten.alchemyapi.io/v2/your-api-key&quot;<br>PRIVATE_KEY = &quot;your-metamask-private-key&quot;</pre><p>To actually connect these to our code, we’ll reference these variables in our hardhat.config.js file on step 13.</p><h3>Step 12: Install Ethers.js</h3><p>Ethers.js is a library that makes it easier to interact and make requests to Ethreum by wrapping <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc">standard JSON-RPC methods</a> with more user friendly methods.</p><p>Hardhat makes it super easy to integrate <a href="https://hardhat.org/plugins/">Plugins</a> for additional tooling and extended functionality. We’ll be taking advantage of the <a href="https://hardhat.org/plugins/nomiclabs-hardhat-ethers.html">Ethers plugin</a> for contract deployment (<a href="https://github.com/ethers-io/ethers.js/">Ethers.js</a> has some super clean contract deployment methods).</p><p>In your project directory type:</p><pre>npm install --save-dev @nomiclabs/hardhat-ethers &#39;ethers@^5.0.0&#39;</pre><p>We’ll also require ethers in our hardhat.config.js in the next step.</p><h3>Step 13: Update hardhat.config.js</h3><p>We’ve added several dependencies and plugins so far, now we need to update hardhat.config.js so that our project knows about all of them.</p><p>Update your hardhat.config.js to look like this:</p><pre>/**<br>* @type import(&#39;hardhat/config&#39;).HardhatUserConfig<br>*/<br>require(&#39;dotenv&#39;).config();<br>require(&quot;@nomiclabs/hardhat-ethers&quot;);<br>const { API_URL, PRIVATE_KEY } = process.env;<br>module.exports = {<br>   solidity: &quot;0.7.3&quot;,<br>   defaultNetwork: &quot;ropsten&quot;,<br>   networks: {<br>      hardhat: {},<br>      ropsten: {<br>         url: API_URL,<br>         accounts: [`0x${PRIVATE_KEY}`]<br>      }<br>   },<br>}</pre><h3>Step 14: Compile our contract</h3><p>To make sure everything is working so far, let’s compile our contract. The compile task is one of the built-in hardhat tasks.</p><p>From the command line run:</p><pre>npx hardhat compile</pre><p>You might get a warning about SPDX license identifier not provided in source file , but no need to worry about that — hopefully everything else looks good! If not, you can always message in the <a href="https://discord.gg/u72VCg3">Alchemy discord</a>.</p><h3>Step 15: Write our deploy script</h3><p>Now that our contract is written and our configuration file is good to go, it’s time to write our contract deploy script.</p><p>Navigate to the scripts/ folder and create a new file called deploy.js , adding the following contents to it:</p><pre>async function main() {<br>   const MyNFT = await ethers.getContractFactory(&quot;MyNFT&quot;);<br>   <br>   // Start deployment, returning a promise that resolves to a contract object<br>   const myNFT = await MyNFT.deploy();<br>   console.log(&quot;Contract deployed to address:&quot;, myNFT.address);<br>}</pre><pre>main()<br>  .then(() =&gt; process.exit(0))<br>  .catch(error =&gt; {<br>    console.error(error);<br>    process.exit(1);<br>  });</pre><p>Hardhat does an amazing job of explaining what each of these lines of code does in their <a href="https://hardhat.org/tutorial/testing-contracts.html#writing-tests">Contracts tutorial</a>, we’ve adopted their explanations here.</p><pre>const MyNFT = await ethers.getContractFactory(&quot;MyNFT&quot;);</pre><p>A ContractFactory in ethers.js is an abstraction used to deploy new smart contracts, so MyNFT here is a factory for instances of our NFT contract. When using the hardhat-ethers plugin ContractFactory and Contract instances are connected to the first signer by default.</p><pre>const myNFT = await MyNFT.deploy();</pre><p>Calling deploy() on a ContractFactory will start the deployment, and return a Promise that resolves to a Contract. This is the object that has a method for each of our smart contract functions.</p><h3>Step 16: Deploy our contract</h3><p>We’re finally ready to deploy our smart contract! Navigate back to the root of your project directory, and in the command line run:</p><pre>npx hardhat run scripts/deploy.js --network ropsten</pre><p>You should then see something like:</p><pre>Contract deployed to address: 0x81c587EB0fE773404c42c1d2666b5f557C470eED</pre><p>If we go to the <a href="https://ropsten.etherscan.io/">Ropsten etherscan</a> and search for our contract address we should able to see that it has been deployed successfully. The transaction will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qlORqkJ0KBb39Y1m.png" /><figcaption>View your transaction address on Etherscan</figcaption></figure><p>The From address should match your Metamask account address and the To address will say “Contract Creation.” If we click into the transaction, we’ll see our contract address in the To field:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yu-kGK524F12jFvZ.png" /><figcaption>View your contract address on Etherscan</figcaption></figure><p>Yasssss! You just deployed your NFT smart contract to the Ethereum chain 🎉</p><p>To understand what’s going on under the hood, let’s navigate to the Explorer tab in our <a href="https://dashboard.alchemyapi.io/explorer">Alchemy dashboard </a>. If you have multiple Alchemy apps make sure to filter by app and select “MyNFT”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9vAulgWSnJJ_Xf4u.png" /><figcaption>View calls made “under the hood” with Alchemy’s Explorer Dashboard</figcaption></figure><p>Here you’ll see a handful of JSON-RPC calls that Hardhat/Ethers made under the hood for us when we called the .deploy() function. Two important ones to call out here are <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_sendrawtransaction">eth_sendRawTransaction</a>, which is the request to actually write our smart contract onto the Ropsten chain, and <a href="https://docs.alchemyapi.io/alchemy/documentation/alchemy-api-reference/json-rpc#eth_gettransactionbyhash">eth_getTransactionByHash</a> which is a request to read information about our transaction given the hash (a typical pattern when sending transactions). To learn more about sending transactions, check out this tutorial on <a href="https://docs.alchemyapi.io/alchemy/tutorials/sending-transactions-using-web3-and-alchemy">sending transactions using Web3</a>.</p><p>That’s all for Part I of this tutorial. In Part II, we’ll actually <a href="https://medium.com/alchemy-api/how-to-mint-an-nft-8cd51e8eb634">interact with our smart contract by minting an NFT</a>, and in Part III we’ll show you how to<a href="https://medium.com/alchemy-api/how-to-view-your-nft-in-your-wallet-f774f4286e2"> view your NFT in your Ethereum wallet</a>!</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:aab0c546-cc29-4180-8d31-fbce31367277"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide and the biggest players in the NFT space, including OpenSea, Nifty Gateway, Makersplace, Dapper Labs, Zora, NFTfi, Super Rare, Foundation, Enjin, Origin Protocol, Immutable, and more. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d92c8b6b777f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/how-to-write-deploy-an-nft-d92c8b6b777f">How to Create an NFT</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain for Beginners]]></title>
            <link>https://medium.com/alchemy-api/blockchain-for-beginners-133efa591d71?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/133efa591d71</guid>
            <category><![CDATA[alchemy]]></category>
            <category><![CDATA[development-tools]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Tue, 09 Feb 2021 19:25:31 GMT</pubDate>
            <atom:updated>2021-06-23T04:41:22.615Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The only guide you need to understand blockchain!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttt_CAEkUn0ld0MzNYMxmw.png" /></figure><p>Nobody was born understanding how blockchain works — in fact, odds are, you’re probably older than the technology itself!</p><p>We all had to start somewhere. After years of teaching our friends and other developers about the blockchain space, we decided to compile a list of sources that we’ve found most helpful in explaining the major concepts.</p><p>Without further ado…</p><h3>1. Bitcoin Basics</h3><p>We recommend that you start with bitcoin because it is the first blockchain and has a succinct white paper. First read the white paper, and then watch the video. After watching the video, go back and read the white paper again. It should make more sense the second time :)</p><ol><li><a href="https://bitcoin.org/bitcoin.pdf">Bitcoin white paper</a></li><li><a href="https://www.youtube.com/watch?v=bBC-nXj3Ng4">Bitcoin explained (basic) video</a></li></ol><h3>2. Ethereum 101</h3><p>Next, jump into Ethereum. At a high level, Ethereum is like bitcoin, but instead of just payments, the blocks can store and execute smart-contracts (programmable contracts). Read and watch the following, multiple times if necessary.</p><ol><li><a href="https://www.youtube.com/watch?v=jxLkbJozKbY">A Beginner’s Explanation in Plain English</a></li><li><a href="http://ethdocs.org/en/latest/introduction/what-is-ethereum.html">Ethereum overview — just read the first page, you can explore the other pages later</a></li><li><a href="https://www.youtube.com/watch?v=66SaEDzlmP4l">Ethereum creator Vitalik Buterin explains Ethereum</a></li><li><a href="https://blockgeeks.com/guides/ethereum/">Ethereum history and development — read the parts that are interesting to you</a></li><li><a href="https://medium.com/@mattcondon/getting-up-to-speed-on-ethereum-63ed28821bbe">This article covers all bases and introduces some of the largest players/projects in the space</a></li></ol><p>Ethereum 2.0: As more and more transactions are added to the blockchain, how can Ethereum scale? These articles explore scalability in layer 1 (things like sharding or Proof of Stake rather than Proof of Work) and layer 2 (things like off chains).</p><ol><li><a href="https://www.youtube.com/watch?v=M3EFi_POhps">Proof of Stake vs Proof of Work explanation</a></li><li><a href="https://docs.ethhub.io/ethereum-roadmap/ethereum-2.0/eth-2.0-phases/">Ethereum Layer 1</a></li><li><a href="https://medium.com/l4-media/making-sense-of-ethereums-layer-2-scaling-solutions-state-channels-plasma-and-truebit-22cb40dcc2f4">Ethereum Layer 2</a></li></ol><h3>3. Why is Blockchain Important?</h3><p>Now that you have a basic understanding of blockchain, read these articles to learn why blockchain matters, current use cases, and future implications.</p><ol><li><a href="https://medium.com/s/story/why-decentralization-matters-5e3f79f7638e">Why decentralization matters</a></li><li><a href="https://medium.com/bitfwd/top-5-most-compelling-use-cases-for-blockchain-technology-d198e500e3d3">5 best uses for blockchain</a></li><li><a href="https://www.coindesk.com/information/applications-use-cases-blockchains">Blockchain’s potential uses cases by sector</a> or <a href="https://lisk.io/academy/blockchain-basics/use-cases">read this similar summary of blockchain application to different industries</a></li><li><a href="https://hackernoon.com/20-blockchain-use-cases-for-2018-you-should-know-f7d2919c191d">Current use cases — a bit hodge podge but interesting projects</a></li><li><a href="https://medium.com/the-naked-founder/naval-ravikants-36-tweets-on-cryptocurrencies-f9b2b64106c1">Naval Ravikant’s Cryptocurrencies Tweets</a></li></ol><h3>4. Ethereum Block Details</h3><p>For block details and blockchain mechanics, there are a few nuances to grasp. These details aren’t necessary to fully understand how blockchain works at a high level, so check them out at your own interest.</p><ol><li>Ethereum is turing complete while bitcoin is not. In brief, we are used to programming languages that are Turing Complete, and can be programmed to solve any computational problem given enough time and space. Before most computer languages were turing complete, machines were not able to solve multiple computational problems — ie a machine can add, but not multiply. This is the most significant difference between Ethereum and Bitcoin, in that the Ethereum blockchain can be used for smart contracts since it is programmable.</li><li>Merkle Trees are the data structure of blocks on the blockchain. The key point is that its very fast/efficient to check if a transaction/block is true, although more computationally intensive to write. Read this piece on <a href="https://hackernoon.com/merkle-tree-introduction-4c44250e2da7">Merkle Trees</a> and watch this <a href="https://www.youtube.com/watch?v=WF5dNyFOqEc">video</a></li><li><a href="https://pegasys.tech/ethereum-explained-merkle-trees-world-state-transactions-and-more/">What’s in a block?</a></li><li><a href="https://etherscan.io/">Read actual Ethereum blocks as they are added</a></li><li><a href="https://codeburst.io/deep-dive-into-ethereum-logs-a8d2047c7371">Get Logs is the most computationally expensive query</a></li></ol><h3>5. Developer Reading: for both technical and non-technical folks</h3><ol><li><a href="https://kauri.io/collection/5bb65f0f4f34080001731dc2/ethereum-101">Ethereum blockchain 101 — series of great guides</a></li><li><a href="https://kauri.io/article/9a7d8927c9484f879d761981d70a42df/v2/tools-for-dapp-development">Tools summary</a></li><li><a href="https://docs.alchemyapi.io/docs/getting-started">How to use Alchemy API as a node provider</a></li></ol><h3>6. Check Out Cool Projects in the Space</h3><p>The blockchain ecosystem is growing at an astronomical speed. At <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:a7b827c4-e459-4fa3-bb44-623a0059a568">Alchemy,</a> we work with a lot of cool projects that are built on top of the Ethereum blockchain — get inspired by checking out some our <a href="https://alchemyapi.io/customers">customers</a> and links to their platforms.</p><h3>7. Get started with <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:a7b827c4-e459-4fa3-bb44-623a0059a568">Alchemy</a></h3><p>A wise person once said, “you can’t get abs by just reading about them.”</p><p>Your brain is also a muscle, so the best way to fully understand how the blockchain space works is by tinkering with a project of your own! Get started by joining the thousands of developers using Alchemy to build game-changing blockchain applications for free <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:a7b827c4-e459-4fa3-bb44-623a0059a568">here</a>.</p><p>Not sure where to start? Check out these tutorials below:</p><ol><li><a href="https://docs.alchemyapi.io/alchemy/tutorials/simple-web3-script">👩‍💻 Simple Web3 Script</a></li><li><a href="https://docs.alchemyapi.io/alchemy/tutorials/sending-transactions-using-web3-and-alchemy">💸 Sending Transactions Using Web3</a></li><li><a href="https://docs.alchemyapi.io/alchemy/tutorials/hello-world-smart-contract">🌎 Hello World Smart Contract</a></li></ol><p>We can’t wait to see what you’ll build! 🚀</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:a7b827c4-e459-4fa3-bb44-623a0059a568"><em>Alchemy </em></a><em>provides the leading blockchain development platform powering millions of users for 99% of countries worldwide. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=133efa591d71" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/blockchain-for-beginners-133efa591d71">Blockchain for Beginners</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Alchemy Amplify: Supercharge Your Growth]]></title>
            <link>https://medium.com/alchemy-api/introducing-alchemy-amplify-supercharge-your-growth-47f1df03642?source=rss-43f668fa37a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/47f1df03642</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Sumi Mudgil]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 21:52:50 GMT</pubDate>
            <atom:updated>2021-03-04T23:47:14.864Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Your go-to launch partner — letting developers and content creators focus on your products while we handle the hype</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GsZi3svrOqqz8B00jK7O3A.png" /><figcaption>Alchemy Amplify: Supercharge Your Growth</figcaption></figure><p>After months of workshopping, we are super excited to finally launch Alchemy Amplify — the marketing machine for YOUR products and content.</p><h3>Why</h3><p>So you spent a ton of time building a killer decentralized application — now the final challenge is just getting people to use it.</p><p>We’ve been there, and we get it. Just as hard (if not harder) as building a game-changing product is sharing it with the world and growing your audience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJzq3949eO-vorMaJHqzUg.png" /></figure><h3>Alchemy Amplify</h3><p>That’s why we’re launching Alchemy Amplify, so you can bootstrap user adoption with our extensive network to maximize your product visibility and to instantly start building credibility in the blockchain space. We’re insanely proud of all the work being done by the talented teams using our platform, and we want to amplify YOU!</p><p>The open-source nature of the blockchain space has greatly shortened the product innovation cycle and with Amplify you can now streamline your go-to-market strategy. Ultimately you are the developers and content creators that will build products for the millions of blockchain believers around the world; we just want to help make that moment happen right now!</p><h3>Partner with Amplify</h3><p>Build your audience in five ways:</p><ol><li><strong>Go Viral on our Socials: </strong>Instantly reach and build relationships with loyal users that turn into evangelists</li><li><strong>Get Featured in our Newsletter: </strong>Reach your audience and connect with users that are already looking for your product or content in our <em>Projects to Watch </em>newsletter section</li><li><strong>Be Spotlighted on our Blog: </strong>Share your story with the leading blockchain projects and builders in the space with a <em>Partnership Spotlight</em></li><li><strong>Join our Badge Program: </strong>Join the <em>Certified Infrastructure Alliance</em> alongside the biggest names in the space, and gain credibility and endless rewards</li><li><strong>Alchemy Accelerator: </strong>Scale your growth with<strong> </strong>exclusive access to startup discounts, mentorship, and access to a dedicated 24/7 Web3 support channel.</li></ol><p>Oh, we missed something. Best of all, Amplify is FREE for our users. Not a user yet? Sign up <a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:b6347e30-4a26-426f-bf59-2370d38fcb47">for free here</a>.</p><h3>How to Join</h3><p>Ready to amplify your product to the blockchain world? Send us a short note to amplify@alchemyapi.io that includes:</p><ul><li>The link to your product</li><li>A description of your product</li><li>Why you decided to use Alchemy</li><li>Your Twitter handles (personal and company)</li></ul><p>We can’t wait to supercharge your growth! 🚀 #alchemyapi #amplifyme #built4blockchain</p><p><a href="https://dashboard.alchemyapi.io/signup?referral=affiliate:b6347e30-4a26-426f-bf59-2370d38fcb47"><em>Alchemy</em></a><em> provides the leading blockchain development platform powering millions of users for 99% of countries worldwide. Our mission is to provide developers with the fundamental building blocks they need to create the future of technology, and lower the barrier to entry for developers to build blockchain applications. Alchemy currently powers 70% of the top Ethereum applications and over $15 billion in on-chain transactions, and have been featured on</em><a href="https://techcrunch.com/2019/12/17/alchemy-blockchain/"><em> TechCrunch</em></a><em>, </em><a href="https://www.wired.com/story/startup-aims-decrypt-blockchain-business/"><em>Wired</em></a><em>, </em><a href="https://www.bloomberg.com/news/articles/2019-12-17/stanford-grads-get-school-s-backing-for-their-blockchain-startup"><em>Bloomberg</em></a><em> and numerous other media outlets. The Alchemy team draws from decades of deep expertise in massively scalable infrastructure, AI, and blockchain from leadership roles at technology pioneers like Google, Microsoft, Facebook, Stanford, and MIT.</em></p><p><strong>Never want to miss an update? Subscribe to our newsletter </strong><a href="https://www.alchemyapi.io/newsletter"><strong>here</strong></a><strong>! Be sure to also follow our </strong><a href="https://twitter.com/alchemyplatform?lang=en"><strong>Twitter</strong></a><strong> and join our </strong><a href="https://discord.com/invite/u72VCg3"><strong>Discord</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47f1df03642" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alchemy-api/introducing-alchemy-amplify-supercharge-your-growth-47f1df03642">Introducing Alchemy Amplify: Supercharge Your Growth</a> was originally published in <a href="https://medium.com/alchemy-api">Alchemy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>